+ Reply to Thread
Results 1 to 4 of 4

Why am I getting a Type Mismatch error when using some items from a listbox in a function?

  1. #1
    Registered User
    Join Date
    06-17-2021
    Location
    Washington, USA
    MS-Off Ver
    Current
    Posts
    19

    Why am I getting a Type Mismatch error when using some items from a listbox in a function?

    First off, here is my code:

    Please Login or Register  to view this content.
    This is working great on a few of the items in my list box. However, most of them give me a type mismatch error, and the fact that it's not working on some items but is on others with no discernible difference between the items is confusing.

    I have tried replacing Val with CInt or CLng but that hasn't helped, and I'm a bit out of my depth here.

    Am I missing something simple?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,469

    Re: Why am I getting a Type Mismatch error when using some items from a listbox in a funct

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Why am I getting a Type Mismatch error when using some items from a listbox in a funct

    Because you declared variable as String, so never be converted to other data type.
    try
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,066

    Re: Why am I getting a Type Mismatch error when using some items from a listbox in a funct

    Please re-read the forum rules... especially Rule 2.

    Crossposted here:

    https://www.mrexcel.com/board/thread...thers.1238881/
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: Lá fhéile Pádraig sona dhaoibh

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Type mismatch error for countif function
    By vajakos81 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2017, 08:39 AM
  2. [SOLVED] Listbox item not rounding to 2 decimals - Runtime error 13 Type mismatch
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2016, 09:18 AM
  3. listbox runtime error 13 type mismatch
    By aprildu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2015, 02:27 AM
  4. [SOLVED] Type Mismatch when selecting items from a listbox
    By Tayque_J_Holmes in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2012, 04:46 PM
  5. Passing Userform Listbox to sub causes type-mismatch error
    By Kleev in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2005, 04:05 PM
  6. Reload Listbox - type mismatch error
    By Stu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2005, 09:05 PM

Tags for this Thread

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