Consulting

Results 1 to 4 of 4

Thread: Solved: Delete rows from another sheet (Matching)

  1. #1
    VBAX Regular dvenn's Avatar
    Joined
    Jun 2005
    Posts
    41
    Location

    Solved: Delete rows from another sheet (Matching)

    Looking for a method to delete rows from another sheet based of values the active sheet.

    On 1 sheet (activesheet) I have Column A

    1002
    1992
    43982
    104432
    3847

    on another Sheet I have Column A

    1002
    1002
    1002
    104432
    1002
    104432
    234


    What I want is to look at the activesheet values, if the value is present in the other sheet delete that row (but delete every occurence).

    This example the only row that should be left is the 234 Row

    Sugestions?
    Daniel Venn
    Office2003 on Win2K & WinXPSP2

    Most people learn by observation, and there are the few who learn by experimentation. And then there are those who actually TOUCH the fire to see if it's really hot.

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hey there,

    This may work for you ...

    [vba]Sub RemoveFromOtherSheet()
    Dim c As Range
    Application.DisplayAlerts = False
    For Each c In Selection
    With Sheets("LookIn") 'range to delete from
    .AutoFilterMode = False
    .Range("A:A").AutoFilter field:=1, Criteria1:=c.Value
    .Range("A2:A" & Rows.Count).SpecialCells(xlCellTypeVisible).Delete
    .AutoFilterMode = False
    End With
    Next c
    Application.DisplayAlerts = True
    End Sub[/vba]

    Select the range of cells in your first sheet (the activesheet). Change the second sheet name to whatever your sheet name is.

    HTH

  3. #3
    VBAX Regular dvenn's Avatar
    Joined
    Jun 2005
    Posts
    41
    Location
    AS usual Zack..

    A quick yet extremely effective answer!!
    Daniel Venn
    Office2003 on Win2K & WinXPSP2

    Most people learn by observation, and there are the few who learn by experimentation. And then there are those who actually TOUCH the fire to see if it's really hot.

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Glad it works for you Daniel.

Posting Permissions

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