(Solved) – Change entire row color if the first characters in a cell is “-“

  • by
(solved)-–-change-entire-row-color-if-the-first-characters-in-a-cell-is-“-“

I would like to change entire row color if the first character of the cells in column A = “-“

Here is my work, I successfully color the row, but it also colored other rows, which the first character of the cells in column A <> “-“

CEll A1 (-ABS) ///////////////////
CEll A2 (12345-Surface Import) —-> I don’t want this row to be colored

Dim Wb3 As Excel.Workbook
Set Wb3 = Application.Workbooks("Test template.xlsm")

Dim ws As Worksheet

For Each ws In Wb3.Sheets

 Dim SrchRng3 As Range
 Dim c3 As Range, f As String


 Set SrchRng3 = ws.Range("A1", ws.Range("A65536").End(xlUp))
 Set c3 = SrchRng3.Find("-*", LookIn:=xlValues)
 If Not c3 Is Nothing Then
 f = c3.Address
 Do
 With ws.Range("C" & c3.Row & ":N" & c3.Row)
 .Font.ColorIndex = 2
 .Interior.ColorIndex = 24
 End With
 Set c3 = SrchRng3.FindNext(c3)
 Loop While c3.Address <> f
 End If


Next


End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *