This is ok:
But this is not, even though I've seen code scripted in this manner before and it works(?) (everything is the same, its just not on 1 line like the first code... it even "corrects me" by automatically changing the "Else CommandButton28" to "Else: CommandButton28... ) It "accepts" the code when I type it in and enter it... but when its executed I get "Compile error: Next without For" (even though its the same thing as the first code I posted and I do not get the "next without for" when its ran.)
I dont care if I've made myself look like complete idiot by asking this... I really want to understand and learn VBA.
THanks
Code:
Dim lCol As Long
lCol = ActiveSheet.UsedRange.Columns.Count
For Each Cell In Range(Cells(4, 6), Cells(4, lCol)).SpecialCells(xlCellTypeVisible)
If Cell = "E" Then Call Macro2 Else CommandButton28.BackColor = &H8000000F
Next
End Sub
But this is not, even though I've seen code scripted in this manner before and it works(?) (everything is the same, its just not on 1 line like the first code... it even "corrects me" by automatically changing the "Else CommandButton28" to "Else: CommandButton28... ) It "accepts" the code when I type it in and enter it... but when its executed I get "Compile error: Next without For" (even though its the same thing as the first code I posted and I do not get the "next without for" when its ran.)
Code:
Dim lCol As Long
lCol = ActiveSheet.UsedRange.Columns.Count
For Each Cell In Range(Cells(4, 6), Cells(4, lCol)).SpecialCells(xlCellTypeVisible)
If Cell = "E" Then
Call Macro2
Else: CommandButton28.BackColor = &H8000000F
Next
End Sub
I dont care if I've made myself look like complete idiot by asking this... I really want to understand and learn VBA.
THanks