Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
delete columns based on selection | Excel Discussion (Misc queries) | |||
Copy Selection - Transpose Selection - Delete Selection | Excel Discussion (Misc queries) | |||
Delete Entry Based on Selection | Excel Discussion (Misc queries) | |||
Listbox & Selection | Excel Discussion (Misc queries) | |||
ListBox selection | Excel Programming |