kingofaces
Board Regular
- Joined
- Aug 23, 2010
- Messages
- 68
I have an array variable that I'm looping through to calculate its values based on a row and column variable. I'm not having any issues with doing that for calculations, but one column I would like to include in the array is already in the excel spreadsheet. Could someone explain how I would refer to an entire column in an array and basically "paste" the entire column from excel into it?. I expect this would speed things up instead of needing to go through each cell in the column, retrieve it's value, and enter it into the array one value at a time through a loop. The example statement below should show what I'm trying to do:
So the basic question is, is there a way to refer to the third column in the array like "Predict25Array(Column3)" and have it contain all the values that I am referring to in the worksheet range? Basically it should be the equivalent of copying one column in a worksheet and pasting it to another column in a worksheet, but instead it's being pasted into an array. It seems like there should be a cleaner way of doing that than using loops because of that. I just picked up on using arrays recently, so hopefully it's just something simple I haven't picked up yet that would make such a statement work.
Code:
ReDim Predict25Array(1 To Endrow, 1 To Endcolumn)
Predict25Array(Column3) = Worksheets("Sheet1").Range("G3:G103")
'loops for all other values in array
So the basic question is, is there a way to refer to the third column in the array like "Predict25Array(Column3)" and have it contain all the values that I am referring to in the worksheet range? Basically it should be the equivalent of copying one column in a worksheet and pasting it to another column in a worksheet, but instead it's being pasted into an array. It seems like there should be a cleaner way of doing that than using loops because of that. I just picked up on using arrays recently, so hopefully it's just something simple I haven't picked up yet that would make such a statement work.
Last edited: