+ Reply to Thread
Results 1 to 4 of 4

Drag cell formula down as far as the data range goes with VBA

  1. #1
    Registered User
    Join Date
    10-02-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    3

    Drag cell formula down as far as the data range goes with VBA

    Hi everyone, I have a spreadsheet in 2003 that holds four columns of data which is a variable size range (some days it could be 25 rows, some days 5000 rows) so I created a dynamic range to run a pivot table from. This works fine, but I want to convert the time column to "Time since start" so essentially current time - origninal time, which means using a formula down the side of the pivot table. The question is, can I somehow only put this formula down as far as the pivot table runs? I have sent the formula to the bottom of the sheet for now but it makes the file huge and isn't really best practice!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,550

    Re: Drag cell formula down as far as the data range goes with VBA

    Can we see a sample workbook and the current code, please?


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-02-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    3

    Re: Drag cell formula down as far as the data range goes with VBA

    Book1.xls

    I have had to take out 90% of the workbook to get it to a decent size, the file attached is basically what I want to do though.

    The column I highlighted in yellow contains a formula to add a description to the data which comes in from a .csv file. There will be more or less records depending on how big the .csv file is and how many records there are but I have a few instances where I need to do this so dragging the formula to the end of the page makes the file in excess of 90mb which isn't ideal.

    What I want is a VB script that I can assign to a button which either performs the action of the Vlookup instead of a formula, or a script which drags the formula to the bottom of the data. I hope that makes sense?

    And thanks for the quick reply!

  4. #4
    Registered User
    Join Date
    10-02-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    3

    Re: Drag cell formula down as far as the data range goes with VBA

    As a footnote to that:

    The data ranges are all dynamic in my workbook all with names (for example "CSV_import" so the VBA I guess would be something like this:

    Test the size of "CSV_import"
    CSV_Import = x

    Drag formula down to the size of x

    Obviously that is just the logic I expect it to take, my problem is i'm not sure how to go about actually writing it

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Macro to drag a formula from [Cell] to [Cell Range]
    By levitt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-06-2014, 02:44 AM
  2. [SOLVED] Drag cell formula for paired data
    By Phily915 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-11-2014, 01:09 PM
  3. [SOLVED] Drag down range formula (skipping one row)
    By thaphthia in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-08-2013, 12:52 PM
  4. Drag down range formula but skip 4 cells
    By diksha_16 in forum Excel General
    Replies: 4
    Last Post: 06-25-2012, 06:54 AM
  5. range stays the same when i drag the formula!!
    By Jfin in forum Excel General
    Replies: 3
    Last Post: 07-30-2008, 03:21 AM

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