|
-
Sep 18th, 2006, 09:23 AM
#1
Thread Starter
Frenzied Member
Quick way to populate cells from arrays ?
I have half a dozen arrays that populate a sheet.
At the mo I am populating the sheet in the worst (slowest) possible way, i.e. using acivecell.offset and then moving down a line and repeating etc.
Theres a much better way to do this .. but I can't remember it.
Can anyone remind me ?
Ta
-
Sep 18th, 2006, 10:48 AM
#2
Re: Quick way to populate cells from arrays ?
You can copy the whole array to a range of the same dimensions.
Here's a simple example
VB Code:
Sub CopyArrayDemo()
Dim aMyData()
Dim x, y
ReDim aMyData(1 To 5, 1 To 2)
For x = 1 To 5
For y = 1 To 2
aMyData(x, y) = x * y * 10
Next y
Next x
ThisWorkbook.Worksheets(1).Range("A1:B5").Value = aMyData
End Sub
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Sep 18th, 2006, 10:52 AM
#3
Thread Starter
Frenzied Member
Re: Quick way to populate cells from arrays ?
Thats a good idea .. although 2 elements of the array I have to check and do a "If this value then do this else do this" scenario, so I'm not sure if that scuppers things.
I'll have a play around and see what I can come up with.
Cheers Kenny !
-
Sep 19th, 2006, 04:02 AM
#4
Re: Quick way to populate cells from arrays ?
I can't recall if I did this and got it working, but if your range is of one cell I think you can paste in an single array of values horizontally.
something like:
Code:
set rng = sht.cells(1,1)
rng=ary()
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|