VBA error when trying to delete row when sum equals o

Anonymous
2016-01-02T02:50:11+00:00

The address in range is =sum ("C2:K2") and is correct, rng equals 0. but I don't know what it can be to make this statement correct. Please help. Trying to delete row when sum equals 0.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

12 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Anonymous
    2016-01-04T03:01:18+00:00

    Unfortunately, this didn't work. The "=sum" is still causing an error. I tried reworking the code, but I couldn't get it to work.

    0 comments No comments
  3. Anonymous
    2016-01-04T03:03:40+00:00

    As a side note, I might test for SUM(   as this has a higher chance of being a function then just "SUM"

    (Range name, or an actual Cell ie  SUM1   )

    Perhaps something like:

        If Left$(Rng.Formula, 5) = "=SUM(" And Rng.Value = 0 Then Rng.EntireRow.Delete

    Not sure if you would find this useful:

    A10 has the formula:   =SUM(D10:J10)

        Debug.Print [A10].DirectPrecedents.Address(False, False)

    Returns:

    D10:J10

    > ...   it is best to sum the row then delete if the entire row is "0".

        For R = 10 To 1 Step -1

            If WorksheetFunction.Sum(Rows(R)) = 0 Then Rows(R).Delete

        Next R

    = = = = =

    HTH  :>)

    Dana

    I'll try this and let you know. Thanks.

    0 comments No comments
  4. Kevin Jones 7,225 Reputation points Volunteer Moderator
    2016-01-04T04:24:33+00:00

    There is a better way--without formulas--but we need to understand the basic task before we can devise an optimal solution.

    Please elaborate on this statement: "find 0's both joined by rows and columns to delete".

    What rows? What columns? What are you "joining" on?

    Try to explain the objective without including any of your current solution that you posted above.

    Kevin

    0 comments No comments
  5. Anonymous
    2016-01-04T04:57:43+00:00

    If you can upload your file a precise solution can be provided.

    0 comments No comments