+ Reply to Thread
Results 1 to 5 of 5

How to autofill down using VBA

  1. #1
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2021
    Posts
    1,019

    How to autofill down using VBA

    Hi,

    I suspect this is an easy one but i'm struggling to crack it myself. I have a report that imports data and i'd like the first column to autofill the unique transaction ID (basically the line number - 1,2,3 etc) to the bottom of the data range. The size of the data range varies everytime I refresh the report and this is where I am struggling because when I try to create the vba required by recording a macro the macro creates a fixed autofill range based on the size of the latest refreshed data.

    I hope this makes sense? I've attached a basic example of the data i'm working with.

    Thanks in advance,

    Snook
    Attached Files Attached Files
    Last edited by The_Snook; 04-08-2013 at 08:02 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: How to autofill down using VBA

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2021
    Posts
    1,019

    Re: How to autofill down using VBA

    That works a treat, thanks!

    I need to build in a similar solution for an additional column I require that contains a formula to be copied down (column B). Any chance you could take a peek at the amended example i've attached?

    Thanks,

    Snook

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: How to autofill down using VBA

    I have combined both the solutions into 1 code - and it also puts in the concatenate formula for you -
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2021
    Posts
    1,019

    Re: How to autofill down using VBA

    You are the man, thank you!

+ 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