Consulting

Results 1 to 4 of 4

Thread: Solved: Deleting rows with odd conditions

  1. #1
    VBAX Newbie
    Joined
    Aug 2007
    Posts
    4
    Location

    Solved: Deleting rows with odd conditions

    Ok so I know I'm making this much harder than this is so here's my dilemna.

    I want to delete rows that have any sort of info in Column C.
    and
    I also want to delete rows where Column B equals zero.

    I want to get it into VBA so I can assign buttons but can't figure out where to start.

    Thanks in advance.

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

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '<=== change to suit
    Dim i As Long
    Dim iLastRow As Long

    With ActiveSheet

    Application.ScreenUpdating = False

    iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
    For i = iLastRow To 1 Step -1
    If .Cells(i, "C").Value <> "" Or _
    .Cells(i, "B").Value = 0 Then
    .Rows(i).Delete
    End If
    Next i

    Application.ScreenUpdating = True

    End With

    End Sub
    [/vba]
    ____________________________________________
    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 Newbie
    Joined
    Aug 2007
    Posts
    4
    Location
    Thank you so much. It worked beautifully.

  4. #4
    VBAX Regular n8Mills's Avatar
    Joined
    Sep 2006
    Location
    Washington State
    Posts
    54
    Location
    Hi, Rudy,

    Make sure to mark this as "Solved" (look in the Thread Tools)

    thx,

    Nate

Posting Permissions

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