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
Rows(Rng2.Row)instead ofRng2.EntireRow- Scott CranerRng2? DoingWorksheetFunction.Sum(rng2.entireRow)worked for me, doingDim rng2 as Range // set rng2 = Sheets("Sheet1").Range("A1"). Since you're saying it works on some sheets, and not others, I think you probably are not declaringrng2with the worksheet it's on? See how I didSheets("Sheet1").Range(...)? You should be sure to declare yourRng2similarly. - BruceWaynerng2is only my cell range that i'm using for the loop. it is a public variable i've declared but is not set. - Mike Mann