J
Jeff W.
I want to create this sub or macro that will start at row 2 and cell A
test for the a word and if this is found then select the cells on that row
from A to H and change the format adding color to the cells based on
the word found.
This is what I have so far, but it doesnt work...
It runs but it doesnt change anything, I'm lost, I'm not a vba programmer
but this does make sence to me, sort of...
Sub color_rows()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 2 To lastrow
a_num = RowCount 'row index
h_num = RowCount + 7 'cell index
If Cells(RowCount) = "Open" Then ' test for the word "Open"
Cells("a_num:h_num").Select ' select cells A to H in the
current row
With Selection.Interior ' this would change the
format of the selected cells
.ColorIndex = 4
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If Cells(RowCount) = "Waiting" Then ' test for the word "Waiting"
Cells("a_num:h_num").Select ' select cells A to H in the
current row
With Selection.Interior ' this would change the
format of the selected cells
.ColorIndex = 27
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If Cells(RowCount) = "Closed" Then ' test for the word "Closed"
Cells("a_num:h_num").Select ' select cells A to H in the
current row
Selection.Interior.ColorIndex = xlNone ' this would change the color to
none
End If
Next RowCount
End Sub
If anyone see's something wrong with this, I could sure use the help...
Thanks,
Jeff W.
test for the a word and if this is found then select the cells on that row
from A to H and change the format adding color to the cells based on
the word found.
This is what I have so far, but it doesnt work...
It runs but it doesnt change anything, I'm lost, I'm not a vba programmer
but this does make sence to me, sort of...
Sub color_rows()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 2 To lastrow
a_num = RowCount 'row index
h_num = RowCount + 7 'cell index
If Cells(RowCount) = "Open" Then ' test for the word "Open"
Cells("a_num:h_num").Select ' select cells A to H in the
current row
With Selection.Interior ' this would change the
format of the selected cells
.ColorIndex = 4
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If Cells(RowCount) = "Waiting" Then ' test for the word "Waiting"
Cells("a_num:h_num").Select ' select cells A to H in the
current row
With Selection.Interior ' this would change the
format of the selected cells
.ColorIndex = 27
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If Cells(RowCount) = "Closed" Then ' test for the word "Closed"
Cells("a_num:h_num").Select ' select cells A to H in the
current row
Selection.Interior.ColorIndex = xlNone ' this would change the color to
none
End If
Next RowCount
End Sub
If anyone see's something wrong with this, I could sure use the help...
Thanks,
Jeff W.