makeitwork09
Technical User
I'm using Excel 2007. I've looked through similar posts and I have tried the solutions for those posts with my own code, but am still getting the error.
I have several sheets that have different postions where range I want to sum starts and ends. Therefore, I created what I have below
the line with the error is
I also tried it as
I have several sheets that have different postions where range I want to sum starts and ends. Therefore, I created what I have below
Code:
Sub CalcPrice()
Dim rRowFound As Range, ws As Worksheet, LastRow As Long, CFLastRow As Integer
For Each ws In Worksheets
If IsNumeric(ws.Name) Then
Set rRowFound = ws.Columns(1).Find(what:="1", after:=ws.Range("A4"), LookIn:=xlValues, LookAt:= _
xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
If Not rRowFound Is Nothing Then
LastRow = ws.Cells(Cells.Rows.Count, "E").End(xlUp).Row
CFLastRow = LastRow
ws.Range(ws.Cells(2, 8)).Formula = "=SUM(" & ws.Range("R" & rRowFound.Row, "R" & CFLastRow) & ")/G2*100"
End If
End If
Next
End Sub
the line with the error is
Code:
ws.Range(ws.Cells(2, 8)).Formula = "=SUM(" & ws.Range("R" & rRowFound.Row, "R" & CFLastRow) & ")/G2*100"
I also tried it as
Code:
ws.Range(ws.Cells(2, 8)).Formula = "=SUM(" & ws.Range(ws.cells(rRowFound.row,18),ws.cells(CFLastRow,18 )) & ")/G2*100"