![]() |
Delete Row Based on Listbox Selection
I have a listbox that pulls data from a worksheet. I want to give the user
the ability to delete the row that he/she has selected in the listbox. Listbox Results Oranges Apples Bananas Pears The user selects Bananas and then clicks the cmdDelete button and then it deletes thr row. I have the code to resort after the delete. Thank you in advance. |
Delete Row Based on Listbox Selection
Hi,
Sub DeleteSelectedData() Assuming data to be matched is in column A: last = Cells(Rows.Count, "A").End(xlUp).Row Set rng = Range("A1:A" & last) For i = last To 1 Step -1 If rng(i).Value = Listbox1.value Then ' e.g = "bananas" rows(i).Entirerow.Delete End If Next End Sub HTH "Hartman" wrote: I have a listbox that pulls data from a worksheet. I want to give the user the ability to delete the row that he/she has selected in the listbox. Listbox Results Oranges Apples Bananas Pears The user selects Bananas and then clicks the cmdDelete button and then it deletes thr row. I have the code to resort after the delete. Thank you in advance. |
All times are GMT +1. The time now is 01:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com