How do I use VBA to find the last row...it moves every week

agiammo

Board Regular
Joined
May 9, 2002
Messages
68
I have recorded a macro that will enter a formula in an empty column. It should enter the formula for every row that is populated. My macro specifies a range that doesn't change as the file grows. How do I edit my macro so it will 'find the last row'?

Here is my code:

Range("K2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-5]=Data!RC[-5],""ok"",""WRONG"")"
Range("K2").Select
Selection.Copy
Range("K2:N2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("K2:N495")
Range("K2:N495").Select
This message was edited by agiammo on 2002-05-10 13:43
This message was edited by agiammo on 2002-05-10 14:00
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
This code will duplicate your procedure to the last completed row in column F:

Code:
Sub cPy()
Dim i As Long
i = [f65536].End(xlUp).Row 'change F to correct column
[k2] = "=IF(F2=Data!F2,""ok"",""WRONG"")"
[k2].Copy Range("k2:n" & i)
End Sub

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,435
Members
448,898
Latest member
dukenia71

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