This runs fine in module or worksheet I have...
but excel doesnt like it one bit when its in a userform... Its probably the structure of how I need to define the range, but I cannot figure it out.
I get the error: "Compile error: Variable not defined" with "Cell" highlighted in the VBA window.
Please and thank you for any help/suggestions.
Keith
Code:
Dim lCol As Long
Dim wt As Worksheet
Set wt = Worksheets("Employee Training Matrix")
lCol = ActiveSheet.UsedRange.Columns.Count
With wt
For Each Cell In Range(Cells(4, 7), Cells(4, lCol))
If Cell = "b" Then Columns(Cell.Column).Hidden = True Else Columns(Cell.Column).Hidden = False
Next
End With
but excel doesnt like it one bit when its in a userform... Its probably the structure of how I need to define the range, but I cannot figure it out.
I get the error: "Compile error: Variable not defined" with "Cell" highlighted in the VBA window.
Please and thank you for any help/suggestions.
Keith