Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi everybody, I have just started using VBA with excel and ran into the followin problem: If I want to fill an array with an excel column I can do: array_in = Range("A1:A7").Value this works fine. But now I want to create a two dimensional array wher I want to fill each dimension with a different excel column (the tw columns have an empty column in between them). So I tried: array_in = Range("A1:A7,C1:C7").Value however this didn't worked out. Of course I can do: array_in = Range("A1:C7").Value, but then I create a three dimensiona array with the second dimension empty. This will work but seems rathe silly to me;-) Maybe I am overlooking something obvious but as a excuse I am only a starter;-) Can somebody help me? Thanks, Stev -- koalabee ----------------------------------------------------------------------- koalabeer's Profile: http://www.excelforum.com/member.php...fo&userid=2989 View this thread: http://www.excelforum.com/showthread.php?threadid=49605 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To the best of my knowedge, you can't do what you ask unless you load the
array cell by cell -- Regards, Tom Ogilvy "koalabeer" wrote in message ... Hi everybody, I have just started using VBA with excel and ran into the following problem: If I want to fill an array with an excel column I can do: array_in = Range("A1:A7").Value this works fine. But now I want to create a two dimensional array where I want to fill each dimension with a different excel column (the two columns have an empty column in between them). So I tried: array_in = Range("A1:A7,C1:C7").Value however this didn't worked out. Of course I can do: array_in = Range("A1:C7").Value, but then I create a three dimensional array with the second dimension empty. This will work but seems rather silly to me;-) Maybe I am overlooking something obvious but as an excuse I am only a starter;-) Can somebody help me? Thanks, Steve -- koalabeer ------------------------------------------------------------------------ koalabeer's Profile: http://www.excelforum.com/member.php...o&userid=29898 View this thread: http://www.excelforum.com/showthread...hreadid=496056 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Steve,
When you stated : "Of course I can do: array_in = Range("A1:C7").Value, but then I create a three dimensional array with the second dimension empty." It is still a two dimensional array, one dimension for the rows, another for the columns. Each element in array_in only needs two reference numbers to identify its position in the array, a row reference and a column reference and you are stuck with the blank column array_in(1 to 7,2). Stick with using arrays, they are much, much faster than processing the equivalent Range object. You just have to write your code so that the blank column is skipped Eg If every second column is blank and using a For Next loop... For iRow = 1 to Ubound(array_in , 1) For iColumn = 1 to Ubound(array_in,2) Step 2 Do Something Next iColumn Next iRow Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding the longest contiguous 1-d array of 0's | Excel Discussion (Misc queries) | |||
summing non-contiguous array cells | Excel Worksheet Functions | |||
Multiplying Contiguous Values in an Array | Excel Worksheet Functions | |||
change the 8th column in a not contiguous array | Excel Programming | |||
Creating an array from non-contiguous ranges | Excel Programming |