+ Reply to Thread
Results 1 to 5 of 5

Get value of column from each line in multiline listbox

  1. #1
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Get value of column from each line in multiline listbox

    I currently have a Listbox, which gets populated by different comboboxes and textboxes (amount + other info).
    When saving the userform, I'd like write to excel cells.

    The values that need to get written to certain cells, depends on the input. Users can modify or delete lines in the listbox, so I only want to check and write when the document gets saved.

    Column 3 of each line gets a certain number (81,82,83) assigned, depends on the input.
    I'm looking for a way to add up the amounts per number and write this to different cells in my spreadsheet.

    Example:

    Purchase of books 300 81
    Water 5.5 81
    Rent 799 82

    So totals should be 305.5 for '81' and 799 for '82
    Is there a generic line of code to collect values from different listbox lines?

    I'm not looking for a pre-made code, just some hints to show me the way .


    Many thanks in advance!

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

    Re: Get value of column from each line in multiline listbox

    You can loop through the rows in a listbox like this.
    Please Login or Register  to view this content.
    Within that loop you can loop through each row's columns like this.
    Please Login or Register  to view this content.
    Combining the two you could have something like this.
    Please Login or Register  to view this content.
    Obviously in that example the message box is for illustration, you could have code in it's place to do whatever it is you actually want to do.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Re: Get value of column from each line in multiline listbox

    Thank you VERY much for the fast reply, I'll let you know if I could work it out.

  4. #4
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Re: Get value of column from each line in multiline listbox

    When I use this code, I get an error message 'Sub of Function is not defined'. The MsgBox part gives the error (MsgBox"hello" works OK).
    How can I define in which column I want to search a specific integer?

    Using the example from the first post:
    Search for integer 81 in column 3 and get the amount from the row where integer 81 is found.

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

    Re: Get value of column from each line in multiline listbox

    The error is caused by a typo.

    If you only wanted to loop down column 3 and find each row where 81 is found you could use someting like this.
    Please Login or Register  to view this content.

+ 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. Get value of column from each line in multiline listbox
    By pclaesen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2015, 10:20 PM
  2. [SOLVED] MultiLine Textbox to auto remove blank line, count line, remove duplicate
    By khhoa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-24-2015, 09:28 PM
  3. Help with Multiline textbox and removing a line from it
    By yoursamrit2000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-09-2015, 12:57 AM
  4. Populating text to a textbox from a listbox multiline in sequence.
    By molesy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2014, 03:37 AM
  5. Populating userform listbox from sheet cell with multiline text
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2013, 07:44 AM
  6. Excel 2007 : How to read multiline comment in single line
    By SWAPNILAGRAWAL in forum Excel General
    Replies: 1
    Last Post: 06-07-2010, 03:38 PM
  7. Pass value and add line to multiline textbox
    By fredpox in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2010, 06:02 AM

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