+ Reply to Thread
Results 1 to 2 of 2

how do you multiple select and delete rows that the data you select are in

  1. #1
    Registered User
    Join Date
    07-18-2005
    Posts
    24

    how do you multiple select and delete rows that the data you select are in

    what is the vba code to delete the rows that the data you select from a list box. also how do you multiple select the data. the code i used is this

    Sub RemoveDuplicate() Dim AllCells As Range, Cell As Range Dim NoDupes As New Collection Dim i As Integer, j As Integer
    Dim Swap1, Swap2, Item

    ' The items are in A1:A105 Set AllCells = Range("p2:p1105")

    ' The next statement ignores the error caused
    ' by attempting to add a duplicate key to the collection.

    On Error Resume Next For Each Cell In AllCells NoDupes.Add Cell.Value, CStr(Cell.Value) Note: the 2nd argument (key) for the Add method must be a string Next Cell

    ' Resume normal error handling On Error GoTo 0

    ' Update the labels on UserForm1 With UserForm4 .Label1.Caption = "Total Items: " & AllCells.Count .Label2.Caption = "Unique Items: " & NoDupes.Count End With

    ' Sort the collection (optional) For i = 1 To NoDupes.Count - 1 For j = i + 1 To NoDupes.Count If NoDupes(i) > NoDupes(j) Then
    Swap1 = NoDupes(i) Swap2 = NoDupes(j) NoDupes.Add Swap1, before:=j NoDupes.Add Swap2, before:=i
    NoDupes.Remove i + 1 NoDupes.Remove j + 1 End If Next j Next i

    ' Add the sorted, non-duplicated items to a ListBox
    For Each Item In NoDupes UserForm4.ListBox1.AddItem Item Next Item

    ' Show the UserForm UserForm4.Show End Sub
    Last edited by kckar; 04-23-2007 at 08:10 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    kckar,

    Please read forum rules below and then wrap your code

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1