Consulting

Results 1 to 3 of 3

Thread: Solved: Deleting Rows

  1. #1
    VBAX Regular
    Joined
    Jul 2008
    Posts
    35
    Location

    Question Solved: Deleting Rows

    I am trying to parse out a team sport schedule to different tabs. Thus far, I have copied Sheet1 ("Season") to Sheets 2&3 ("Home" & "Away").

    On the Home tab, I want to delete all the "at" rows (column e).

    On the Away tab, I want to delete all the "vs" rows (Column e).

    Thanks for the help.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Dim i As Long
    Dim LastRow As Long
    Dim rng As Range
    Dim rngCopy As Range

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
    Set rng = .Range("E1").Resize(LastRow)

    rng.AutoFilter field:=1, Criteria1:="at"
    Set rngCopy = rng.SpecialCells(xlCellTypeVisible)
    If Not rngCopy Is Nothing Then

    rngCopy.EntireRow.Copy Worksheets("Home").Range("A1")
    End If

    rng.AutoFilter field:=1, Criteria1:="vs"
    Set rngCopy = rng.SpecialCells(xlCellTypeVisible)
    If Not rngCopy Is Nothing Then

    rngCopy.EntireRow.Copy Worksheets("Away").Range("A1")
    End If
    End With

    End Sub
    [/vba]
    Last edited by Bob Phillips; 08-09-2008 at 02:26 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jul 2008
    Posts
    35
    Location
    Quote Originally Posted by xld
    [vba]

    Public Sub ProcessData()
    Dim i As Long
    Dim LastRow As Long
    Dim rng As Range
    Dim rngCopy As Range

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
    Set rng = .Range("E1").Resize(LastRow)

    rng.AutoFilter field:=1, Criteria1:="at"
    Set rngCopy = rng.SpecialCells(xlCellTypeVisible)
    If Not rngCopy Is Nothing Then

    rngCopy.EntireRow.Copy Worksheets("Home").Range("A1")
    End If

    rng.AutoFilter field:=1, Criteria1:="vs"
    Set rngCopy = rng.SpecialCells(xlCellTypeVisible)
    If Not rngCopy Is Nothing Then

    rngCopy.EntireRow.Copy Worksheets("Away").Range("A1")
    End If
    End With

    End Sub
    [/vba]
    Thanks!!! As always, top notch help

Posting Permissions

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