On Tue, 1 Jun 2004 20:46:51 -0700, John Keturi wrote:
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
Be a bit more consistent with your indenting, and this sort of error
would stick out like a sore thumb:
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
The problem is there's no End If for the second If. Also,
VB doesn't
need "Next b" and "Next a" - you can leave them both as just "Next" with
no problems.
--
auric underscore underscore at hotmail dot com
*****
- Suck the marrow out of life, that's what I say.
- But will you swallow?
- NO, smarty pants. Well, not on the first date, anyway.