I have some Code that does a number of things but currently I am looking to get the value of a SumIf into a cell on my worksheet. My Data is on the 'CheckerSheet' and the criteria I am matching is on the 'DiscrepancySheet'. The sheets are in separate workbooks and both workbooks are open.
I am getting a 1004 error Method 'Range' of Object '_Worksheet' failed. Debugging points me to the first line of the For statement. Replacing '.Cells(i, 2)' with a string that matches one of the options gets it to work so I know the problem is there but I cant seem to figure it out. I have tried the following options![]()
With DiscrepancySheet .Cells(1, (MaxColumn + 1)).Value = Format(Date, "d-mmm") .Cells(1, (MaxColumn + 2)).Value = "Delta" For i = 2 To MaxRow .Cells(i, (MaxColumn + 1)).Value = WorksheetFunction.SumIf(CheckerSheet.Range(Cells(7, 3), Cells(CheckerMaxRow, 3)), .Cells(i, 2), CheckerSheet.Range(Cells(7, 5), Cells(CheckerMaxRow, 5))) .Cells(i, (MaxColumn + 2)).Value = Application.Sum(.Cells(i, MaxColumn), .Cells(i, (MaxColumn + 1))) Next i End With
I know this probably going to be a simple fix and I am going to feel like an idiot but it's stumping me right now.![]()
.Cells(i, 2) .Cells(i, 2).Value DiscrepancySheet.Cells(i, 2) DiscrepancySheet.Cells(i, 2).Value
Thanks in advance for the assist!!











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks