Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete columns based on selection Steve Excel Discussion (Misc queries) 0 December 7th 09 09:38 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Delete Entry Based on Selection AntnyMI Excel Discussion (Misc queries) 1 September 16th 06 06:24 PM
Listbox & Selection sparx Excel Discussion (Misc queries) 0 July 31st 06 10:48 PM
ListBox selection GMet Excel Programming 1 September 24th 04 08:02 PM


All times are GMT +1. The time now is 02:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"