+ Reply to Thread
Results 1 to 7 of 7

Excel VBA Listbox on a Userform

  1. #1
    Registered User
    Join Date
    02-07-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    18

    Excel VBA Listbox on a Userform

    Hello,

    I am just needing some help with a small piece of code...

    I get the code working fine, except it will only do the first line after the THEN statement, however wont do the lines for text boxes 2 and 3. Should I be placing an AND statement or anything?

    Many thanks,

    Andrew

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Excel VBA Listbox on a Userform

    Excel VBA Listbox on a Userform
    Where's the ListBox mentioned in the title?

  3. #3
    Registered User
    Join Date
    02-07-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Excel VBA Listbox on a Userform

    Hi Cytop,

    For some reason I cant upload an attachment as an example, however I have included the whole code below which is linked to the update button on the userform. Essentially I am wanting the userform to edit the data in Sheet 1.

    Cheers,

    Andrew

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Excel VBA Listbox on a Userform

    The IF code is working. The problem is the listbox control using a rowsource and you updating it. If you step through the code you will see that the first change of data on the sheet causes the listbox event to fire which updates the contents of the textboxes before their values have been update on the sheet

    this should fix it.
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    02-07-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Excel VBA Listbox on a Userform

    Thankyou very much for your assistance Andy, I understand what you have done, however I am now getting a "Compile Error Sub or Function not found" DO i need to define the store text or all or am I on the wrong track? Thanks heaps Andrew

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Excel VBA Listbox on a Userform

    You need to declare the array that stores the values

    Please Login or Register  to view this content.
    I missed that in the posted code snippet

  7. #7
    Registered User
    Join Date
    02-07-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Excel VBA Listbox on a Userform

    Thankyou so much! Works perfectly...

+ 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] if anything in listbox select first item, if listbox empty do nothing (listbox in userform
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 12:49 PM
  2. [SOLVED] copy contents of userform listbox to another userform listbox
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2014, 11:39 AM
  3. Transfer Data From One Userform Listbox to Another Userform Listbox with 11 columns
    By sparkoft in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2013, 10:54 AM
  4. listbox in excel userform
    By sujithy007 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-03-2013, 07:27 AM
  5. userform listbox
    By tsiguy96 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-14-2013, 11:09 PM
  6. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  7. Excel VBA Userform Listbox
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-30-2009, 10:43 AM

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