Results 1 to 10 of 10

ListBox Code for VBA form

Threaded View

  1. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: ListBox Code for VBA form

    Hi,

    The way I'd do this is create a dynamic range name for your invoice list. e.g.

    lst_inv :
    Formula: copy to clipboard
     =OFFSET(MasterData!$A$1,0,0,COUNTA(MasterData!$B:$B),7)


    change the 7 to change the number of columns you see in the ListBox

    Set the RowSource property of the Listbox to lst_inv
    Set the ColumnWidth Property to say
    30 pt;60 pt;60 pt;60 pt;60 pt;60 pt - change the numbers as necessary to display the number of characters from each field.

    Use the

    Private Sub FindButton_Click()
    Me.InvoiceList.RowSource = Range("inv_list")
    End Sub
    procedure to list the invoices.

    That's a starter for 10.

    I'd then use the click event of the listbox to identify the row that's been selected and use that that row number to index the row in the Master Data sheet that contains the details and populate the form fields with the data from that row.


    See attached
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA code to change a chart based on a selection from a listbox on a form
    By cinstanl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2016, 03:07 PM
  2. User Form ListBox - Find Records (ListBox Populating Issue)
    By LONeillSSC in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-20-2015, 12:06 PM
  3. Is it possible to do that using a Listbox Form?
    By Rech in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2014, 10:08 AM
  4. Form Control Listbox VBA
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2009, 05:36 AM
  5. Modification of listbox to listbox code
    By Sam S via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2005, 07:05 AM
  6. listbox value to a form
    By alexanderd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2005, 12:05 PM
  7. vb6 form with listbox
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-02-2005, 07: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