+ Reply to Thread
Results 1 to 3 of 3

Stopping Autofill at alst line of file

  1. #1
    Registered User
    Join Date
    08-25-2005
    Posts
    7

    Stopping Autofill at alst line of file

    I use the code below to autofill columns,(using formulas), which is done successfully except that it creates garbage past the last line of the file.

    Range("V2:AF2").AutoFill Destination:=Range("V2", Range("AF2").End(xlDown)(0))

    How can I stop it doing this to row 65536?
    Thanks

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    leskoby

    There are several ways to do this. Here is one way

    This finds last row with data in it then autofills down to that row

    Dim GetBottomRow As Long
    GetBottomRow = Cells.Find(what:="*", SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious).Row


    Range("v2:af2").AutoFill Destination:= _
    Range("v2:af" & GetBottomRow), Type:=xlFillDefault

  3. #3
    Registered User
    Join Date
    08-25-2005
    Posts
    7

    It worked!!

    Thanks Mudraker, worked like a charm.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1