Oberon70
Board Regular
- Joined
- Jan 21, 2022
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
Hi,
I keep receiving the below message:
for the below macro
FindLast runs a macro that obtains the last cell for the last row with data in it.
The below is A & the variable i combined
The below is the results from FindLast(3)
when I run MsgBox rng_2.address
I appreciate any help.
I keep receiving the below message:
for the below macro
VBA Code:
Sub Delete_Last_2_Rows()
Dim i As Long
Dim rng_1 As Range
Dim rng_2 As Range
Dim ws As Worksheet
Set ws = Sheets("Data")
Set rng_1 = Range("A:A")
ws.Select
i = WorksheetFunction.CountA(rng_1) + 2
'MsgBox "A" & i
'MsgBox FindLast(3)
'MsgBox "A" & i & ":" & FindLast(3)
Set rng_2 = ws.Range("A" & i & ":" & FindLast(3))
ws.Rows(rng_2).Select
Selection.Delete Shift:=xlUp
End Sub
FindLast runs a macro that obtains the last cell for the last row with data in it.
The below is A & the variable i combined
The below is the results from FindLast(3)
when I run MsgBox rng_2.address
I appreciate any help.