Using Last Row with a Formula

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
946
Office Version
  1. 2016
Platform
  1. Windows
Hello All...
Having a little trouble here
I have the following codes:

Dim Lst As Long
VBA Code:
Lst = Range("A:A").Cells.Find("*", _
SearchOrder:=xlByRows, searchdirection:=xlPrevious).Row

And

VBA Code:
Range("M2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-8]=""No Tag Found-"","""",RC[-8])"
Selection.AutoFill Destination:=Range("M2" & Lst), Type:=xlFillDefault
Range("M2" & Lst).Select
Range("A1").Select

and it's not working...

If I use:
VBA Code:
    Range("M2").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-8]=""No Tag Found-"","""",RC[-8])"
    Selection.AutoFill Destination:=Range("M2:M20"), Type:=xlFillDefault
    Range("M2:M20").Select
    Range("A1").Select
It does work, however I wish the formula to go to the last row and not only to Row 20...
What am I doing wrong?
Thanks

PS what I'm trying to accomplish, is in column M, to only display what is in column E that only has a mixture of Text and Numbers like: LB667
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I believe you're trying to auto-fill your column M2 to the last row of column A. If so try:
VBA Code:
    Range("M2").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-8]=""No Tag Found-"","""",RC[-8])"
    Selection.AutoFill Destination:=Range("M2:M" & Range("A" & Rows.count).End(xlUp).Row)
    Range(Selection, Selection.End(xlDown)).Select
    Range("A1").Select
 
Upvote 0
Instead of putting one formula in and then filling down, you could just put them all in at once with a single line:

VBA Code:
Range("M2:M" & Range("A" & Rows.Count).End(xlUp).Row).FormulaR1C1 = "=IF(RC[-8]=""No Tag Found-"","""",RC[-8])"
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top