![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Location: Austin, TX
Posts: 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 ] |
|
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Location: Austin, TX
Posts: 68
|
Thanks! This works perfectly!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|