Bryan,
I am trying your macro below to do something similar, but am running into a
"Compile Error: Sub or Function not defined" error. I am creating a formula
in cell F2, want to copy this formula down to the last used row, then cutting
and pasting these values over to the corresponding cells in column D The
macro so far, with the error on the 9th row listed:
Range("F2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]/RC[1]"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]/R2C[1]"
Dim nLastRow As Long
' Find the last row on data in column F
nLastRow = Range("F3" & Rows.Count).End(xlUp).Row
' build a variable representing the last cell in the column
nTheRange = F3: F " & nLastRow"
Range("F2").Select
Selection.Copy
Range(nTheRange).Select
ActiveSheet.Paste
nTheRange = F2: F " & nLastRow"
Range(nTheRange).Select
Selection.Copy
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Any help?
Bryan Kelly said:
This finds the last row as part of adding a new column and extending a
formula down to the last row.
Sub Add_Elapsed_Time_Column()
'
Dim nLastRow As Long
' Find the last row on data in column C
nLastRow = Range("C" & Rows.Count).End(xlUp).Row
' build a variable representing the last cell in the column
nTheRange = "C4:C" & nLastRow
'
'
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Selection.NumberFormat = "0.0"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Elapsed Time"
Range("C2").Select
ActiveCell.FormulaR1C1 = "0"
Range("C3").Select
ActiveCell.FormulaR1C1 = "=R[-1]C + 0.1"
Range("C3").Select
Selection.copy
Range(nTheRange).Select
ActiveSheet.Paste
End Sub