Using multiple conditions
Hi John
If I understand what you are trying to do is to shade intersecting cells
where column A contains John and row 2 contains Fri ?
If I'm right then you need to change your code as follows.....
Sub test()
Dim a As Integer, b As Integer
For a = 4 To 31
If Cells(a, 1).Value = "John" Then
For b = 2 To 32
If Cells(2, b).Value = "Fri" Then
With Cells(a, b).Interior
.ColorIndex = 0
.Pattern = xlGray8
.PatternColorIndex = xlAutomatic
End With
End If
Next b
End If
Next a
MsgBox "Formatting Complete"
End Sub
Cheers
Nigel
"John Keturi" wrote in message
news:G4cvc.40419$mm1.15189@fed1read06...
The following generates an error "Next" without a "For". What do I put in
so
that it formats the cell which corresponds to the following row & column
parameters?
For a = 4 To 31
If Cells(a, 1).Value = "John" Then
For b = 2 To 32
If Cells(2, b).Value = "Fri" Then
Cells(b, a).Select
With Selection.Interior
.ColorIndex = 0
.Pattern = xlGray8
.PatternColorIndex = xlAutomatic
End With
Next b
End If
Next a
MsgBox "Formatting Complete"
Exit Sub
Error:
Exit Sub
End Sub
Thanks
|