+ Reply to Thread
Results 1 to 3 of 3

Using Autofill in a macro with variable rows

  1. #1
    Registered User
    Join Date
    05-18-2007
    Posts
    1

    Using Autofill in a macro with variable rows

    Hi all,

    I've searched extensively and have been unable to find the answer I need.

    My issue is fairly simple, I'm trying to create a macro that will autofill into column B based on data in column A. Insofar as I can record the macro with a stated range, the range of values changes.

    I'm hoping someone can show me how to code my macro so that the autofill function will only populate column B to the end row of column A.

    Thanks!

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Once you have recorded your macro for the exact range, edit it so that the row number of the column B range is determined by the last row in A

    for instance...

    Range("B1:B100")

    would become...

    Range("B1:B" & Range("A65536").end(xlup).row)


    An alternative is

    Range("B1:B" & Range("A1").end(xldown).row)

    but this one will fail if there are blank cells in A or if there is only one cell in A.

+ 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