Hi all,
I would like to create a macro that highlights multiple columns in Excel when the first row of the column is equal to "1". I was able to find the solution for one column but I would like to do the same for 50 or more columns and I don't want to copy and paste my code. Is there any easier way? Here is my current code for the first column but I need one for 50:
Sub colorColumn()
If (Range("A1").Value = "1") Then
Range("A2:A50").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
Range("A2:A50").Select
Selection.Interior.ColorIndex = xlNone
End If
End Sub
Thanks,
Armel
I would like to create a macro that highlights multiple columns in Excel when the first row of the column is equal to "1". I was able to find the solution for one column but I would like to do the same for 50 or more columns and I don't want to copy and paste my code. Is there any easier way? Here is my current code for the first column but I need one for 50:
Sub colorColumn()
If (Range("A1").Value = "1") Then
Range("A2:A50").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
Range("A2:A50").Select
Selection.Interior.ColorIndex = xlNone
End If
End Sub
Thanks,
Armel