[RESOLVED] Why do I get a type mismatch error?
In the active sheet I have a button that shows a userform vbmodeless which lists, by name, certain columns in the worksheet. The OK button works if the column isn't hidden but if it is I get the error. Why?
Here is my code.
Code:
Private Sub cmdOK_Click()
Dim rng As Range
Dim strColName As String
Set rng = Range("1:1").Find(lstLabels.Value, LookIn:=xlFormulas)
If Not rng Is Nothing Then
rng.EntireColumn.Hidden = True
Else
strColName = lstLabels.Value
Columns(strColName).EntireColumn.Hidden = False
End If
End Sub
Re: Why do I get a type mismatch error?
Re: Why do I get a type mismatch error?
In my case I'm trying to hide and unhide columns on the active sheet and not worksheets.
Re: Why do I get a type mismatch error?
It could still be the same issue though. Did you try it to see if it made a difference?
Re: Why do I get a type mismatch error?
Thank you for your efforts. I resolved the problem which was partially due to the fact that the range should have been 2:2 and not 1:1.