Excel - VBA : delete table row from listbox selection

devofish

Board Regular
Joined
Dec 10, 2016
Messages
68
I've got some delete code
Code:
    Rw = Me.ListBox1.ListIndex + 2
If Me.ListBox1.ListIndex > -1 Then Sheets(1).Cells(Rw, 5).Resize(1, 5).Value = ""
The code works great if the sheet data is in non-table format, but all my data ranges are in tables. How do I use ListRow to delete a table record using a combobox selection? The row needs to move up after deletion. I recorded a macro deleting entire row 4
Code:
Row(4:4).Select
What does (4:4) mean? My table is 'n' rows and 5 columns
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
How about something like this, assuming the Table you want to delete the row from is named "Table1"

Code:
rw = Me.ListBox1.ListIndex + 2
If Me.ListBox1.ListIndex > -1 Then Sheets(1).ListObjects("Table1").ListRows(rw).Delete
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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