ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Last Row (https://www.excelbanter.com/excel-programming/312036-re-last-row.html)

jmdaniel

Last Row
 
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" wrote:

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

"scottnshelly " wrote in
message ...
Please translate the following commands into working code.

find the last row
go down one more row
go to column A, type "TOTAL"
go to columns d:l and insert formula =sum(counta(d3:d*))
range (a1) select

* = the row above current row.


---
Message posted from http://www.ExcelForum.com/







All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com