+ Reply to Thread
Results 1 to 6 of 6

Macro: Listbox value null

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit
    Posts
    3,711

    Macro: Listbox value null

    This macro was working yesterday, today I can't get it to work no matter what I do (I've cut it out, saved, closed, reopened, tried different naming conventions) and I'm getting pretty frustrated, so am hoping for some help.

    The code does 2 things:
    1) Copies the selection from the Listbox ("RegionSelect") to another worksheet ("Steps")
    2) Uses that value to copy and paste other items into the same sheet.

    The first part is working, the second part gives me a "Run-Time error '94': Invalid Use of Null" error on this line:

    Please Login or Register  to view this content.
    The full code is reproduced below:
    Please Login or Register  to view this content.
    Last edited by jomili; 12-04-2009 at 04:49 PM. Reason: Solved

  2. #2
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Akron, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    208

    Re: Macro: Listbox value null

    Look at the items in red. Why this worked before I'm not sure? Comment out the RegionSelect.Selected(Item) = False and see if it does what you want it to.

    Please Login or Register  to view this content.
    Last edited by jrdnoland; 12-03-2009 at 07:04 PM.

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Macro: Listbox value null

    Jrdnoland's response covers off your situation, but for interest sake - you can test for null in other situations by using
    Please Login or Register  to view this content.
    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit
    Posts
    3,711

    Re: Macro: Listbox value null

    Tried jrdnoland's fix (Commented out the RegionSelect.Selected(Item) = False) and still getting the same error on the same line. Any other ideas? Here's the code as it now stands:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Akron, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    208

    Re: Macro: Listbox value null

    jamili - I'm going to assume that you picked the last item in the list and in that case the value will still be False thus causing the Null to occur.

    The best solution would be if you could provide the workbook and let me look at the whole process.

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit
    Posts
    3,711

    Re: Macro: Listbox value null

    Consider this one solved. I abandoned the code I was using, and changed the way the listbox worked. Rather than populating the listbox from the Rowsource (in Properties), I used this procedure in the initialization code...
    Please Login or Register  to view this content.
    ... then used the following to do the copy and paste.

    Please Login or Register  to view this content.
    I'm trying to learn this stuff, and have been scouring the internet looking for code I can modify and use, though I'm having a tough time understanding it. But I really appreciate you guys being willing to help.

    Thanks.

+ 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