Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gds Gds is offline
external usenet poster
 
Posts: 2
Default Deleting Rows with Listbox

Tom,

I just found this in Google. Thank you for the code. This has saved me
hours or maybe days.

Gds

Tom Ogilvy wrote:
This worked in Excel 2000 given that the listbox is populated using

the
rowsource property. It assumes that the user is deleting rows that

populate
the listbox and that the listbox is on a userform:

Private Sub CommandButton1_Click()
Dim sRange As String
Dim rng As Range
Dim rng1 As Range
With UserForm1
sRange = .ListBox1.RowSource
Set rng = Range(sRange)
Set rng1 = Nothing
For i = 0 To .ListBox1.ListCount - 1
If .ListBox1.Selected(i) = True Then
If rng1 Is Nothing Then
Set rng1 = rng(i + 1, 1)
Else
Set rng1 = Union(rng1, rng(i + 1, 1))
End If
.ListBox1.Selected(i) = False
End If
Next i
End With
rng1.EntireRow.Delete
End Sub

Regards,
Tom Ogilvy



"Michael" wrote in message
...
Can anyone help.

I would like to use a multi select listbox so the user can delete

rows
from the worksheet. Does anyone know how I can make this work? I

have
only been able to make it delete one row even if more than one row

was
selected.

Thanks in advance.

Regards Michael


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
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Deleting Duplicate items in a ListBox CLamar Excel Discussion (Misc queries) 24 June 13th 06 06:22 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM
Deleting Rows with Listbox Gds Excel Programming 0 January 22nd 05 09:12 PM


All times are GMT +1. The time now is 04:45 PM.

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"