Bob Stamm
asked on
Load Array with Values on Excel worksheet
Looking to load array in Excel. Will be assigning this code to a command button.
When selecting the command button all the values will be loaded into an array.
Sheet1
values D5 to ND5
I am just getting back into programming and need an model to get me going. Thanks to anyone that can assist.
When selecting the command button all the values will be loaded into an array.
Sheet1
values D5 to ND5
I am just getting back into programming and need an model to get me going. Thanks to anyone that can assist.
Here's a link to my article on the subject:
https://www.experts-exchange.com/articles/2253/Fast-Data-Push-to-Excel.html
https://www.experts-exchange.com/articles/2253/Fast-Data-Push-to-Excel.html
ASKER
Thank you...that has me going. I tosses in a msgbox to make sure I was getting the data loaded.
thanks again and for the article too.
thanks again and for the article too.
ASKER
I now want to place my data on the "Print Calendar" worksheet. The fill data array captured all the data for 365 days (works great). I just want to place the first 31 days of data on the "Print Calendar" worksheet. I assuming I need some type of loop or is there a more direct statement?
Dim arrData As Variant
arrData = Sheets("Calendar").Range(" D5:ND5").V alue ' fill array with data from D5:ND5
'This statement I wrote places the same value in each cell (I need help here).
Sheets("Print Calendar").Range("B55:AF55 ").Value = arrData(1, 2) ' Place calendar data for January
End Sub
Dim arrData As Variant
arrData = Sheets("Calendar").Range("
'This statement I wrote places the same value in each cell (I need help here).
Sheets("Print Calendar").Range("B55:AF55
End Sub
Try this.
Sheets("Print Calendar").Range("B55").Resize(,31).Value = arrYear
Note, I've used Resize(,31) to expand the destination range for the data by 31 columns.
ASKER
Starting to get there. If I need to grab from 32 to 60 out of arrData how is that done? This would be for my month of February.
Dim arrData As Variant
arrData = Sheets("Calendar").Range(" D5:ND5").V alue ' fill array with data from D5:ND5
Sheets("Print Calendar").Range("B55").Re size(,31). Value = arrData ' January Data
Sheets("Print Calendar").Range("B56")... ..??? ' February Data
End Sub
Dim arrData As Variant
arrData = Sheets("Calendar").Range("
Sheets("Print Calendar").Range("B55").Re
Sheets("Print Calendar").Range("B56")...
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
This worked great. Thank you for your help.
Open in new window
Note the above code will produce a 2-dimensional array with the dimensions 1 to 1, 1 to 365, i.e. 1 row and 365 columns, if you like.