Hello,
I'm attempting to do some simple worksheetfunctions on a column of values (# of values is likely to change and needs to be dynamic) and to place that SUM (or MAX , MIN) in an offset cell below the column. Data will always start in D7. Here's what I have so far:
'Create first and last row for formulas
lastrow = Sheets("SC").Cells(Sheets("SC").Rows.Count, "B").End(xlUp).Row
firstrow = Sheets("SC").Cells(lastrow, "B").End(xlUp).Row
Dim lastrow As Long
Range("D7").End(xlDown).Offset(4, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(D7:D & lastrow)"
My result comes back with a #NAME, so I'm not sure I'm using correct way to find lastrow, or if something is wrong with SUM formula.
Thank you!
I'm attempting to do some simple worksheetfunctions on a column of values (# of values is likely to change and needs to be dynamic) and to place that SUM (or MAX , MIN) in an offset cell below the column. Data will always start in D7. Here's what I have so far:
'Create first and last row for formulas
lastrow = Sheets("SC").Cells(Sheets("SC").Rows.Count, "B").End(xlUp).Row
firstrow = Sheets("SC").Cells(lastrow, "B").End(xlUp).Row
Dim lastrow As Long
Range("D7").End(xlDown).Offset(4, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(D7:D & lastrow)"
My result comes back with a #NAME, so I'm not sure I'm using correct way to find lastrow, or if something is wrong with SUM formula.
Thank you!