Results 1 to 20 of 20

Trouble writing huge array into worksheet range

Threaded View

  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Trouble writing huge array into worksheet range

    I admit I'm still learning the mechanics of building large-set arrays in memory, then writing the resulting data out to the worksheet all at once at the end.

    I've written a macro that builds a one-dimensional array in memory
    Dim MyArr as Variant, NR as Long
    
    Redim MyArr (1 to 1)
    NR=1
    
    'Large macro that builds the dataset and adds a new value, but for example:
    MyArr(NR) = "1,5,7,12,26,27,49000,36.22"
    NR=NR+1
    Redim Preserve MyArr(1 To NR)
    Over simplified, of course. End result, MyArr in memory has 68722 rows and each row is unique.

    Question - how do I write MyArr out to G2:G68723 in one swoop?

    I've tried:
    Range("G2").Resize(UBound(MyARR)).NumberFormat = "@"
    Range("G2").Resize(UBound(MyARR)).Value = MyARR
    ..but this seems to just write out the FIRST value from MyArr into all those rows. Instead the 68722 unique strings I've built, I get MyArr(1) over and over. So I think I'm close, but no cigar.

    Extra Credit - the REAL goal is to split this array into 8 columns, parsing by the commas. I've tried:
    Range("G2").Resize(UBound(MyARR), 8).Value = Split(WorksheetFunction.Transpose(MyARR), ",")
    and
    Range("G2").Resize(UBound(MyARR), 8).Value = WorksheetFunction.Transpose(Split(MyARR, ","))
    Thanks in advance.
    Last edited by JBeaucaire; 09-23-2015 at 11:40 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Writing elements of array to a range
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2015, 12:42 PM
  2. writing a range to an array then writing the array to a new range
    By prjames3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2014, 08:57 PM
  3. Writing an additional 'IF' into a huge 'IF' formula??
    By grholden in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-24-2014, 06:12 AM
  4. writing formula in range on each sheet via array
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2011, 12:59 PM
  5. Writing a range to an array...
    By Alex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2005, 10:10 AM
  6. Writing an array(2d) of user types to a worksheet
    By John Keith in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2005, 08:30 PM
  7. Writing values to worksheet from array
    By interstellar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-12-2005, 01: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