Hi I want to apply red color to data in excel in a column ,here i dont want to apply color on the column i want to apply only on the data
Hi @T_Y_Raju
You can use the Format cells activity to apply the color to the specified range data in excel.
Click on set format option → Click on Fill tab → Select the color from the dropdown → Click okay
Check the below image for better understanding,
Hope it helps!!
Sub ApplyRedColorToColumnData()
Dim ws As Worksheet
Dim rng As Range
Dim cell As Range
Dim columnNumber As Integer
' Set the worksheet you want to work with
Set ws = ThisWorkbook.Sheets("Sheet1")
' Set the column number you want to apply the color to
columnNumber = 1 ' Example: Column A
' Get the range of the column excluding the header
Set rng = ws.Range(ws.Cells(2, columnNumber), ws.Cells(ws.Rows.Count, columnNumber).End(xlUp))
' Apply red color to each cell in the range
For Each cell In rng
If cell.Value <> "" Then
cell.Interior.Color = RGB(255, 0, 0)
End If
Next cell
End Sub
Try this vb code in Invoke Vba activity hope it works for
not yet iam tryinh with format cell option but iam getting error
Format cells is the modern excel activity you have to use inside the use excel file activity.
→ Use the Excel process scope activity → Insert use excel file activity and provide the path of the file → Inside use excel file activity insert the Format cells activity.
Then it will work, give the range like below,
Excel.sheet("Sheet name").Range("Z"+CellNo.tostring+":Z"+Lastrow.tostring)
Hope it helps!!
ok let me try and check thank you
here i see that column is getting colored in blue ,…i want only the data to be get colored with blue
will this macro will paint column or data in color
it will colour the data only.
columnNumber = 1 ' Example: Column A ----->in this give your column Number
And pass your sheet name
It’s always good to search the forums before posting. There are tons of posts on this already.
i see that cells are getting coloured not the data can you please check once
Sorry for that please check this vb code it will work for you
Sub ApplyRedColorToColumnData()
Dim ws As Worksheet
Dim rng As Range
Dim cell As Range
Dim columnNumber As Integer
' Set the worksheet you want to work with
Set ws = ThisWorkbook.Sheets("Sheet1")
' Set the column number you want to apply the color to
columnNumber = 1 ' Example: Column A
' Get the range of the column excluding the header
Set rng = ws.Range(ws.Cells(2, columnNumber), ws.Cells(ws.Rows.Count, columnNumber).End(xlUp))
' Apply red color to the text in each cell in the range
For Each cell In rng
If cell.Value <> "" Then
cell.Font.Color = RGB(255, 0, 0)
End If
Next cell
End Sub
Output: