Belair58
Board Regular
- Joined
- Mar 31, 2005
- Messages
- 95
Hello,
I'm finding the last row with data in my range and then I'm attempting to use the cell number in a formula.
'''
firstRow = sht.Cells(sht.Rows.Count, "D").End(xlDown).Row
lastRow = sht.Cells(sht.Rows.Count, "D").End(xlUp).Row
Range("E1").Select
ActiveCell.FormulaR1C1 = "Late / OnTime"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=RC[-4]="""""
Range("E2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-4]="""","""",IFERROR(VLOOKUP(RC[-4], Cycle_" & Cycle & "_Output.txt!C1,1,FALSE),""LATE""))"
Range("E2").Select
Selection.Copy
Range("E3").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Columns("E:E").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("E" & lastRow + 1).Select
ActiveCell.FormulaR1C1 = "=ROUND((COUNTIF(E2:" & lastRow",""LATE"")/COUNTA(E2:" & lastRow & ")*100),2)"
'''
I'm receiving a Run-time error 1004
Application-defined or object-defined error
I'm assuming it's because I have the format of the formula incorrect.
Any help is always appreciated.
I've tried wrapping
I'm finding the last row with data in my range and then I'm attempting to use the cell number in a formula.
'''
firstRow = sht.Cells(sht.Rows.Count, "D").End(xlDown).Row
lastRow = sht.Cells(sht.Rows.Count, "D").End(xlUp).Row
Range("E1").Select
ActiveCell.FormulaR1C1 = "Late / OnTime"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=RC[-4]="""""
Range("E2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-4]="""","""",IFERROR(VLOOKUP(RC[-4], Cycle_" & Cycle & "_Output.txt!C1,1,FALSE),""LATE""))"
Range("E2").Select
Selection.Copy
Range("E3").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Columns("E:E").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Range("E" & lastRow + 1).Select
ActiveCell.FormulaR1C1 = "=ROUND((COUNTIF(E2:" & lastRow",""LATE"")/COUNTA(E2:" & lastRow & ")*100),2)"
'''
I'm receiving a Run-time error 1004
Application-defined or object-defined error
I'm assuming it's because I have the format of the formula incorrect.
Any help is always appreciated.
I've tried wrapping