Mike Mann
Mike Mann

Reputation: 546

Error '1004'- Unable to Get Sum Property of the worksheet function Class with defined range variable

Not sure why I'm getting an error on certain worksheets and not others. Any help would be greatly appreciated.

The code line that is getting the error:

    If Rng2.Value = 0 Or Rng2.Value = "" Or Rng2.Offset(0, 3).Value = "Define" Or WorksheetFunction.Sum(Rng2.EntireRow) = Rng2.Value _
        And Rng2.Offset(0, 3).Value <> "" Then

The code is part of this loop:

For Each Rng2 In WorkRng2
    If Rng2.Value = 0 Or Rng2.Value = "" Or Rng2.Offset(0, 3).Value = "Define" Or Application.WorksheetFunction.Sum(Rng2.EntireRow) = Rng2.Value _
        And Rng2.Offset(0, 3).Value <> "" Then
        Rng2.Value = Rng2.Offset(-1, 0).Value
    End If
Next

Rng2 is not a defined range it's a set range variable. WorkRng2 is a set range and a defined variable

Upvotes: 0

Views: 2522

Answers (1)

Mike Mann
Mike Mann

Reputation: 546

For those interested, this code works fine. I was getting an error because I had an #value error in the sum range.

Upvotes: 2

Related Questions