G
Guest
I am developing a macro that among other things hides columns where the text
"Index" is found. However I am encountering the following error:
Run-time Error'91: Object variable or With block variable not set
I have played around with it but I can't seem to get rid of that error..
Can anyone help?
Private Sub ColumnFinder()
Dim FirstAddress As String
Dim c As Variant
'Macro identifies Index columns
With ActiveSheet.Range("a6:iv6")
Set c = .Find("Index", LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
PresentAddress = c.Address
'c.Offset(-1, 0).Value = PresentAddress 'Check step
c.Value = "Index"
'c.Interior.ColorIndex = 3'check step
Call CycleThrough
' Discard columns
c.EntireColumn.Hidden = True<---------This is the problem
statement
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Sub
"Index" is found. However I am encountering the following error:
Run-time Error'91: Object variable or With block variable not set
I have played around with it but I can't seem to get rid of that error..
Can anyone help?
Private Sub ColumnFinder()
Dim FirstAddress As String
Dim c As Variant
'Macro identifies Index columns
With ActiveSheet.Range("a6:iv6")
Set c = .Find("Index", LookIn:=xlValues)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
PresentAddress = c.Address
'c.Offset(-1, 0).Value = PresentAddress 'Check step
c.Value = "Index"
'c.Interior.ColorIndex = 3'check step
Call CycleThrough
' Discard columns
c.EntireColumn.Hidden = True<---------This is the problem
statement
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Sub