Results 1 to 9 of 9

Thread: VBA To Extract Data From Multiple Tables Based On Critera

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Junior Member
    Join Date
    May 2013
    Posts
    20
    Rep Power
    0
    Update: Kind of hacky, but I managed to limit the find/replace to the specific worksheet by doing this before the find/replaces:

    Code:
    Set Dummy = Worksheets(1).Range("A1:A1").Find("Dummy", LookIn:=xlValues)
    Now, just need help on the deleting part, thanks


    This also works for deleting if there are rows with blank values in Column 2 of the table, but throws an error if no blanks were found. Guess it just needs error checking?

    Code:
    Dim RngBlank As Range
        With ActiveSheet.ListObjects("Orig").Range
            .AutoFilter Field:=2, Criteria1:="="
            Set RngBlank = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
            .AutoFilter
            RngBlank.Delete
        End With

    Edit: Looks like I got it. If there's a better way to do it, please let me know.

    Code:
    With ActiveSheet.ListObjects("Orig")
    
            .Range.AutoFilter Field:=2, Criteria1:="="
            
            If .AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1 > 0 Then
                .DataBodyRange.EntireRow.Delete
                .Range.AutoFilter Field:=2
            Else
                .Range.AutoFilter Field:=2
            End If
            
    End With
    Last edited by aaronb; 06-01-2013 at 03:15 AM.

Similar Threads

  1. Replies: 17
    Last Post: 05-22-2013, 11:58 PM
  2. Replies: 2
    Last Post: 03-05-2013, 07:34 AM
  3. VBA Code to Extract data
    By Howardc in forum Excel Help
    Replies: 1
    Last Post: 07-24-2012, 11:37 PM
  4. Replies: 7
    Last Post: 03-06-2012, 07:49 AM
  5. Extract multiple data matching with input
    By excel_learner in forum Excel Help
    Replies: 1
    Last Post: 02-13-2012, 06:08 PM

Tags for this Thread

Posting Permissions

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