need to edit the following code that show only data in the range not empty
not like attached photo
HTML Code:
need to edit the following code that show only data in the range not empty
not like attached photo
HTML Code:
Hello mazan2010,
Please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.
Remember to desensitize the data.
Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
Please consider:
Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
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.
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)
For the first part try this.
Not sure about the second part, what do you want to base the column widths on?![]()
Private Sub UserForm_Initialize() Dim I As Long '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 For I = 0 To .ListCount - 1 .List(I, 4) = Trim(rngSource.Cells(I + 1, 5).Text) Next I End With End Sub
also if applicable to show head of the table in list box or not
Product name Size Batch Volume Number
This line is setting the widths of the 5 columns, in points (pts)W, in the listbox.
It sets the first column to a width 100 pts, the second to 20 pts, the 3rd to 50 pts and so on.![]()
.ColumnWidths = "100;20;50;50;20"
What's the problem with the delete button?
If you just want to delete without a message try this.
![]()
Private Sub CommandButton1_Click() Dim I As Long With ListBox1 For I = .ListCount - 1 To 0 Step -1 If .Selected(I) Then .RemoveItem I Sheets("Waiting list").Rows(I + 2).EntireRow.Delete End If Next I End With End Sub
no i need this message but after press ok nothing is happen (not delete any thing
When I click the delete button the selected row is deleted from the listbox and the sheet.
and can make this message pop
give yes and not instead of ok only
just message coming without any effect
Your message box can only return vbOk, not vbYes or anything else.
ok what about head of table can show in listbox or not
Not unless you use RowSource to populate the listbox.
you mean
instead start from A2 start from A1 in the following line
Set rngSource = Worksheets("Waiting list").Range("A2:E" & .Range("A" & Rows.Count).End(xlUp).Row)
No, I mean use the RowSource property of the listbox to populate the listbox.
There are 3 main ways to populate a listbox:
1 using the RowSource property
2 using List
3 using AddItem
For 1 you set the RowSource property of the listbox to a reference to the range you want to populate it with.
For example if you wanted to populate a listbox, ListBox1 from A1:D20 on Sheet1 you would set the RowSource property to Sheet1!A1:D20.
That can be done manually but here's the code to do it anyway.
If you want headers in your listbox you have to use this method to populate it.![]()
ListBox1.RowSource = "Sheet1!A1:D20"
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks