+ Reply to Thread
Results 1 to 7 of 7

Copying array formula to last row using VBA.

  1. #1
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Copying array formula to last row using VBA.

    Hi all,

    I am using the following macro to copy an array formula from cell B2 down to the last row:

    Please Login or Register  to view this content.
    The formula is copied to the last row of column B, however the formula always refers to value $A2, i.e.
    - Cell B3 should contain formula:
    Please Login or Register  to view this content.
    - Cell B4 should contain formula:
    Please Login or Register  to view this content.
    But they all contain
    Please Login or Register  to view this content.
    Any ideas anyone?

    Thanks.
    Last edited by Folshot; 11-24-2013 at 01:44 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copying array formula to last row using VBA.

    Try this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Copying array formula to last row using VBA.

    Thanks again AlphaFrog, it works great.

    Just one last thing, I would like to live the calculated value in the cell rather than the formula, I tried:

    Please Login or Register  to view this content.
    But it only copies the formula onto the first row

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copying array formula to last row using VBA.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Copying array formula to last row using VBA.

    Sorry for the delay in replying, the above code works fine as long as the calculations are set to automatic (which would make sense). However in my case, it seems that many users set the calculation option to manual (due to the high number of formulas the spreadsheet contains).

    If the formula to copy down to the last row is a 'basic' formula, I use the code below to paste the resulting value, it works fine even if calculations are set to manual:

    Please Login or Register  to view this content.
    The above code works for 'basic' formulas, even with calculations set to manual, but it does not work for array formulas. Is there a way to copy array formulas all the way down to the last row and leaving the resulting value only, when calculations are set to manual?

    I tried adding the following lines to the previous code provided by AlphaFrog (though I would like to avoid enabling automatic calculations, if possible at all), but did not help:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copying array formula to last row using VBA.

    Use the .Calculate method to force calculation for a specified range of cells on a worksheet.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 12-02-2013 at 10:59 AM.

  7. #7
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Re: Copying array formula to last row using VBA.

    Hi AlphaFrog, this is perfect, thanks again!

    Ant

+ 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. Copying an Array Formula
    By alxan2007 in forum Excel General
    Replies: 3
    Last Post: 10-26-2011, 08:10 PM
  2. Copying an array formula
    By geoffreynd in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-13-2008, 04:25 PM
  3. Copying an Array
    By BDH in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-21-2006, 12:15 AM
  4. [SOLVED] Tricky array formula issue - Using array formula on one cell, then autofilling down a range
    By aspenbordr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2005, 11:05 AM
  5. Copying an Array Formula
    By montagu in forum Excel General
    Replies: 1
    Last Post: 07-15-2005, 02:30 PM

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