Results 1 to 4 of 4

Thread: Insert excel formulas from VB array..

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    7

    Question Insert excel formulas from VB array..

    I have been trying to get an array full of formulas to insert into a range on excel spreadsheat; however the formulas end up showing as text and not evaluating. I have tried sever different commands and none seem to work. I currently am outputing one cell's formula at a time but this is painfully slow and i was hoping to improve speed by storing them in an array and puting out the whole array of formulas at one time. Is this possible? and if it is how can it be done. range.formula = array does not seem to work.

  2. #2
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126
    This worked for me:

    VB Code:
    1. Sub usearray()
    2. Xarray = Worksheets(1).Range("C3", "K26").Formula
    3. Worksheets(1).Range("C103", "K126") = Xarray
    4. End Sub

    Don't forget to dim the array as a variant.
    (well actually, I guess if you do forget, it will do it for you anyway... but the point was don't dim as as something other than variant for this to work.)
    Last edited by TheFIDDLER; Apr 5th, 2004 at 04:40 PM.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

  3. #3
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126
    Also your destination range must be the same size as your array.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    7
    Thank You So much the only problem with my code was that i had the array declared as strings. When I changed it it worked. Never would have thought that would affect anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width