Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I want to work at increasing the speed of macros that work with large
ranges. I'm told that I can DIM a variable as VARIANT and assign a range to it. So far so good, but how can that be used? That is, how can maniulate individual elements in that array (if it's correct to call it an array)? Here's the stub I'm working with. Note that I'm simply trying to figure out how these prodcedures work. The data in A1:E1 is 1,2,3,4,5. I want to change the value 1 to 2 and write a range of cells back to A2:E2 that looks like 2,2,3,4,5 (so I know that I actually did something!) Sub TestVariant Dim RgArray as Variant Dim LowBound as Integer, Highbound as Integer Dim MyArray() As Single RgArray = Application.Range("A1:E1") LowBound = LBound(RgArray, 2) HighBound = UBound(RgArray, 2) ReDim MyArray(LowBound To HighBound) 'The next statement DOES NOT WORK and produces an error! 'What I'm trying to do is load all the values in RgArray into the local 'array, manipulate the data, and write it back. MyArray = RgArray 'Does not work MyArray(1) = 2 'What follows works, but since my array is all zeros at this 'point, except for MyArray(1) (because the MyArray = RgArray 'didn't work), I'm not going to get the result I want. Of course, 'I'm getting 2,0,0,0,0. RgArray = MyArray Range ("A2:E2").Value = Rgarray End Sub I'm missing something simple but essential here but I can't find it. What am I missing? -- Mike H |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I want to assign a value to the letter R in a cell range | Excel Worksheet Functions | |||
Cannot assign a range to seriecollection values | Charts and Charting in Excel | |||
Assign number to correct range | Excel Discussion (Misc queries) | |||
Assign number to every value in a data range??? | Excel Worksheet Functions | |||
assign a value to a range | Excel Discussion (Misc queries) |