+ Reply to Thread
Results 1 to 2 of 2

Inserting Formula to a cell from VBA using Array References

  1. #1
    Forum Contributor
    Join Date
    06-12-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    167

    Inserting Formula to a cell from VBA using Array References

    Hello,

    I am trying to create a function for a cell from VBA.

    I have all of the cells addresses I would like to add together stored in an array. (they are not all joined together but rather every third cell in a column )

    I would now like to have the formula be entered to the cell as =sum(array(1)+array(2) ect)

    I am looking for the code so I can just have all of theses come in without having to code it like

    Please Login or Register  to view this content.
    I have 30 cell references so I would really like to not have to type this out 30 times, especially since I plan on using this code to fill more than 100+ cells

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

    Re: Inserting Formula to a cell from VBA using Array References

    Quote Originally Posted by dougman824 View Post
    =sum(array(1)+array(2) ect)
    Using both the SUM function and the Plus operator is redundant. Just use one or the other e.g.;
    =SUM(array(1),array(2), ect)
    Or
    =array(1) + array(2) + ect


    As far as your query, I'm not sure what you're asking.
    This will concatenate each value in the array with a Plus delimiter...

    Range("A1").Formula = "=" & Join(Array, "+")
    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.

+ 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. [SOLVED] Inserting a formula from a sub that references variables
    By vbalearnerdriver in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2014, 01:12 PM
  2. [SOLVED] index match array formula - replace cell references with ranges
    By nigelog in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-17-2014, 10:39 AM
  3. [SOLVED] increment all cell references in an array formula by 24 when copied down a row
    By ariapro22 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-29-2013, 05:51 AM
  4. Keep "IF" formula references after inserting cell(s)
    By dannac in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-12-2013, 09:18 AM
  5. [SOLVED] Inserting a written formula using the IF function & cell references
    By Jaice in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-01-2013, 11:54 PM
  6. Replies: 0
    Last Post: 08-21-2011, 11:53 AM
  7. Cell References When Inserting Rows
    By officeplus215 in forum Excel General
    Replies: 2
    Last Post: 09-30-2005, 09:05 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