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 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
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Deleting Duplicate items in a ListBox CLamar Excel Discussion (Misc queries) 24 June 13th 06 06:22 PM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM


All times are GMT +1. The time now is 02:21 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"