+ Reply to Thread
Results 1 to 21 of 21

edit code for list box only have data

Hybrid View

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

    Re: edit code for list box only have data

    Try this.
    
    Private Sub UserForm_Initialize()
    'Macro Purpose: To populate a multi-column listbox with data from
    '               a worksheet range
        
        Dim lbtarget As msforms.ListBox
        Dim rngSource As Range
        
        'Set reference to the range of data to be filled
        With Worksheets("Waiting list")
            Set rngSource = Worksheets("Waiting list").Range("A2:E" & .Range("A" & Rows.Count).End(xlUp).Row)
        End With
       'Fll the listbox
        Set lbtarget = Me.ListBox1
        With lbtarget
            'Determine number of columns
            .ColumnCount = 5
            'Set column widths
            .ColumnWidths = "100;20;50;50;20"
            'Insert the range of data supplied
            .List = rngSource.Cells.Value
        End With
        
    End Sub
    If posting code please use code tags, see here.

  2. #2
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    dear Norie
    its work good
    i have note if can make it
    in column E the data with decimal i need in listbox not show decimal number for data in column E
    also can explain how can calculated column width as
    .ColumnWidths = "100;20;50;50;20"
    Quote Originally Posted by Norie View Post
    Try this.
    
    Private Sub UserForm_Initialize()
    'Macro Purpose: To populate a multi-column listbox with data from
    '               a worksheet range
        
        Dim lbtarget As msforms.ListBox
        Dim rngSource As Range
        
        'Set reference to the range of data to be filled
        With Worksheets("Waiting list")
            Set rngSource = Worksheets("Waiting list").Range("A2:E" & .Range("A" & Rows.Count).End(xlUp).Row)
        End With
       'Fll the listbox
        Set lbtarget = Me.ListBox1
        With lbtarget
            'Determine number of columns
            .ColumnCount = 5
            'Set column widths
            .ColumnWidths = "100;20;50;50;20"
            'Insert the range of data supplied
            .List = rngSource.Cells.Value
        End With
        
    End Sub

  3. #3
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: edit code for list box only have data

    i mean what mean in this line

    .ColumnWidths = "100;20;50;50;20"

    also do you can look to button for delete what the error (not delete after show the message)

+ 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. edit in code for populate range of cell in list box and code for delete any items
    By mazan2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2017, 03:33 PM
  2. Vba code to edit data that changes with a list box
    By grimston in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2017, 07:59 AM
  3. vba code to edit a csv file in notepad and replace data
    By garveyarmy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2017, 12:12 PM
  4. Edit VBA code to get data from multiple sheets
    By leprince2007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-27-2016, 02:23 AM
  5. find and edit data from list
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2009, 06:34 AM
  6. using list box to edit or select data
    By BigPig in forum Excel General
    Replies: 4
    Last Post: 02-22-2006, 09:35 PM
  7. [SOLVED] using list box to edit or select data
    By BigPig in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-20-2006, 12:15 PM

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