+ Reply to Thread
Results 1 to 4 of 4

unknown type mismatch

  1. #1
    Aonghus
    Guest

    unknown type mismatch

    I have a userform where
    Problems =name of Listbox on the same form as the Checkbox(SFCC_Bite)

    Private Sub SFCC_Bite_Click()
    If SFCC_Bite.Enabled = True Then
    With Problems
    .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    End With
    Problems.Enabled = True
    End If
    End Sub

    as the range on Sheet1 is a list of names
    why does this line give a type mismatch error
    .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    Forgive me I'm reasonably new to VBA.
    Thanks in advance


  2. #2
    Tom Ogilvy
    Guest

    Re: unknown type mismatch

    You are trying to add more than one item. If you want to do that, use

    With Problems
    .List Worksheets("Sheet1").Range("A3:A20").Value
    End With

    --
    Regards,
    Tom Ogilvy


    "Aonghus" <[email protected]> wrote in message
    news:[email protected]...
    > I have a userform where
    > Problems =name of Listbox on the same form as the Checkbox(SFCC_Bite)
    >
    > Private Sub SFCC_Bite_Click()
    > If SFCC_Bite.Enabled = True Then
    > With Problems
    > .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    > End With
    > Problems.Enabled = True
    > End If
    > End Sub
    >
    > as the range on Sheet1 is a list of names
    > why does this line give a type mismatch error
    > .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    > Forgive me I'm reasonably new to VBA.
    > Thanks in advance
    >




  3. #3
    Aonghus
    Guest

    Re: unknown type mismatch

    Thanks Tom

    But now it gives me an Invalid use of property


    "Tom Ogilvy" wrote:

    > You are trying to add more than one item. If you want to do that, use
    >
    > With Problems
    > .List Worksheets("Sheet1").Range("A3:A20").Value
    > End With
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Aonghus" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have a userform where
    > > Problems =name of Listbox on the same form as the Checkbox(SFCC_Bite)
    > >
    > > Private Sub SFCC_Bite_Click()
    > > If SFCC_Bite.Enabled = True Then
    > > With Problems
    > > .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    > > End With
    > > Problems.Enabled = True
    > > End If
    > > End Sub
    > >
    > > as the range on Sheet1 is a list of names
    > > why does this line give a type mismatch error
    > > .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    > > Forgive me I'm reasonably new to VBA.
    > > Thanks in advance
    > >

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: unknown type mismatch

    Sorry, left out the Equal sign:

    With Problems
    .List = Worksheets("Sheet1").Range("A3:A20").Value
    End With

    --
    Regards,
    Tom Ogilvy

    "Aonghus" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks Tom
    >
    > But now it gives me an Invalid use of property
    >
    >
    > "Tom Ogilvy" wrote:
    >
    > > You are trying to add more than one item. If you want to do that, use
    > >
    > > With Problems
    > > .List Worksheets("Sheet1").Range("A3:A20").Value
    > > End With
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Aonghus" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > I have a userform where
    > > > Problems =name of Listbox on the same form as the Checkbox(SFCC_Bite)
    > > >
    > > > Private Sub SFCC_Bite_Click()
    > > > If SFCC_Bite.Enabled = True Then
    > > > With Problems
    > > > .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    > > > End With
    > > > Problems.Enabled = True
    > > > End If
    > > > End Sub
    > > >
    > > > as the range on Sheet1 is a list of names
    > > > why does this line give a type mismatch error
    > > > .AddItem Worksheets("Sheet1").Range("A3:A20").Value
    > > > Forgive me I'm reasonably new to VBA.
    > > > Thanks in advance
    > > >

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1