VBA Userform Listbox

Trickay

New Member
Joined
Aug 5, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi all, how can I make a listbox row source be from columns a to j until the last row that is not blank?

I am then wanting the columns to have borders in between them when being displayed on the listbox and a button to delete a row, and another button to add a row to an empty sheet inside the workbook
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Listboxes don't have internal borders, so you won't find a listbox that looks like a table.

To get the last filled row, you can find it a number of ways. Check this page for tips: VBA Tutorial: Find the Last Row, Column, or Cell in Excel

Then, create a For loop to populate your listbox with each row's data

Adding/Deleting rows is harder.

To delete, you'll need a function to find the selected item in the listbox and then the row associated with that element. I suggest that you create a multicolumn listbox. In one of the columns, store the row number and set its width to 0. Then when you wan t to delete the row, you don't have to search for it, you can use the row number stored in the listbox.

To add, you'll need a function to find the last row, input some data element, then requery the listbox.
 
Upvote 0
Thank you for your reply. Maybe I should have a second userform pop out when the row on the list box is double clicked, and all of that information go into text boxes. Then from there I can already get the text boxes to do what I need.
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,802
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top