Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    Can anyone see where my syntax is wrong here with the IF statement? I need to delete the row if both cells sum to zero.

    Code:
    For z8 = 9 To 2 Step -1
            If Sum("S" & z8 & ":T" & z8) = 0 Then
                Range("A" & z8).EntireRow.Delete
            End If
        Next z8

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    SUM is a worksheet function, not a VBA function.

    Option 1: use

    If Application.WorksheetFunction.Sum(Range("S" & z8 & ":T" & z8)) = 0 Then

    Option 2: use

    If Range("S" & z8) + Range("T" & z8) = 0 Then

  3. #3
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans, I'll (attempt to) note both methods in my ever expanding brain (cell).

Posting Permissions

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