Results 1 to 5 of 5

Thread: [RESOLVED] Why do I get a type mismatch error?

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Resolved [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

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526

    Re: Why do I get a type mismatch error?

    Try adding the specific worksheet reference.

    https://www.mrexcel.com/board/thread...a-vba.1233212/

  3. #3

  4. #4
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526

    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?

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width