Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

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

  1. #1
    Board Regular
    Join Date
    May 2002
    Location
    Austin, TX
    Posts
    68
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  3. #3
    Board Regular
    Join Date
    May 2002
    Location
    Austin, TX
    Posts
    68
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks! This works perfectly!

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •