+ Reply to Thread
Results 1 to 7 of 7

Listbox change event to return two values to different cells

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    6

    Question Listbox change event to return two values to different cells

    Hi,

    I have a list box with four column and a linked cell, however when a user changes the linked cell and updates the lisbox or vice versa I also want another cell to update with data from column 4 on the list box.

    Can this be done through vba code? does it need to be as I know the linkcell is currently used and I dont see a way to link 2 cells in the propertiues of the listbox.

    Any help would be greatly appreciated thanks.

    Andy

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Listbox change event to return two values to different cells

    Andy

    You would need code to do this, though I suppose you might use a formula in the second cell if the 2 values are linked in some way.

    What is the second value? Does it also come from the listbox?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Listbox change event to return two values to different cells

    Yes the second cell value would come from the same data just a different column. I dont want a formula in the cell as the retuned value will be copied out by users to a different program.
    The current linked cell refers to column 1 and the new cell would display the value in column 4.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Perhaps something like this.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-15-2013
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Listbox change event to return two values to different cells

    Sorry, I am not understanding this.
    I the listbox changes the linked cell, what will this code change, should I reference a cell/range that this code puts the value of the 4th column into?

    ie the current linked cell is called acctnum and it is filled with the value in column 1.
    I also want a second linked cell called acctname to be filled with value in column 4.
    is this possible, considering the values will be derived from the same listbox?

    Thanks
    Andy

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Andy

    The code I posted should put the value from column 4 of the listbox in the cell next to the linked cell.

    The code is triggered when a selection is made in the listbox.

    It's really just an example because I don't have many details on your exact setup.

    If you need it to go to a specific cell the code can easily be changed.
    Last edited by Norie; 01-15-2013 at 08:19 AM.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Listbox change event to return two values to different cells

    Here's the updated code with some typos fixed and changed to put the value from column 4 in 'acctname'.
    Please Login or Register  to view this content.
    This code would go in the module of the worksheet the listbox is on.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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