Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am looking to create a new array with elements of a previously
created array. Whe For Each cell In Ratings ReDim Preserve Ratings1(6, rw) Ratings1(0, rw) = Ratings(0, rw) Ratings1(1, rw) = Ratings(1, rw) Ratings1(2, rw) = Ratings(2, rw) Ratings1(3, rw) = Ratings(3, rw) Ratings1(4, rw) = Ratings(4, rw) Ratings1(5, rw) = Ratings(5, rw) rw = rw - 1 Next Cell "Ratings" is my old array and "Ratings1" is my new array that i am creating. "Ratings" is in the same sub and will have the same number of row elements. For some reason this is not working. When im done not all elements of Ratings1 will be the same as the Ratings, but im just trying figure this part out. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What are you trying to do?
You setup a loop to look through each cell in Ratings, then ignore the value obtained each time. You redim your array each iteration of the loop, thereby losing data each time. etc. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message oups.com... I am looking to create a new array with elements of a previously created array. Whe For Each cell In Ratings ReDim Preserve Ratings1(6, rw) Ratings1(0, rw) = Ratings(0, rw) Ratings1(1, rw) = Ratings(1, rw) Ratings1(2, rw) = Ratings(2, rw) Ratings1(3, rw) = Ratings(3, rw) Ratings1(4, rw) = Ratings(4, rw) Ratings1(5, rw) = Ratings(5, rw) rw = rw - 1 Next Cell "Ratings" is my old array and "Ratings1" is my new array that i am creating. "Ratings" is in the same sub and will have the same number of row elements. For some reason this is not working. When im done not all elements of Ratings1 will be the same as the Ratings, but im just trying figure this part out. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Aug 22, 8:38 am, "Bob Phillips" wrote:
What are you trying to do? You setup a loop to look through each cell in Ratings, then ignore the value obtained each time. You redim your array each iteration of the loop, thereby losing data each time. etc. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message oups.com... I am looking to create a new array with elements of a previously created array. Whe For Each cell In Ratings ReDim Preserve Ratings1(6, rw) Ratings1(0, rw) = Ratings(0, rw) Ratings1(1, rw) = Ratings(1, rw) Ratings1(2, rw) = Ratings(2, rw) Ratings1(3, rw) = Ratings(3, rw) Ratings1(4, rw) = Ratings(4, rw) Ratings1(5, rw) = Ratings(5, rw) rw = rw - 1 Next Cell "Ratings" is my old array and "Ratings1" is my new array that i am creating. "Ratings" is in the same sub and will have the same number of row elements. For some reason this is not working. When im done not all elements of Ratings1 will be the same as the Ratings, but im just trying figure this part out. Thanks- Hide quoted text - - Show quoted text - I guess i am just trying to create a new array with old array elements, but i see your point however i am using redim preserve and not just redim. I want to create array Ratings1 from Ratings. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
not just redim. I want to create array Ratings1 from Ratings.
If you mean copy Ratings to Ratings1, simply Ratings1 = Ratings Ratings may have been declared as an array but .... Dim Ratings1 as Variant Regards, Peter T wrote in message ups.com... On Aug 22, 8:38 am, "Bob Phillips" wrote: What are you trying to do? You setup a loop to look through each cell in Ratings, then ignore the value obtained each time. You redim your array each iteration of the loop, thereby losing data each time. etc. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message oups.com... I am looking to create a new array with elements of a previously created array. Whe For Each cell In Ratings ReDim Preserve Ratings1(6, rw) Ratings1(0, rw) = Ratings(0, rw) Ratings1(1, rw) = Ratings(1, rw) Ratings1(2, rw) = Ratings(2, rw) Ratings1(3, rw) = Ratings(3, rw) Ratings1(4, rw) = Ratings(4, rw) Ratings1(5, rw) = Ratings(5, rw) rw = rw - 1 Next Cell "Ratings" is my old array and "Ratings1" is my new array that i am creating. "Ratings" is in the same sub and will have the same number of row elements. For some reason this is not working. When im done not all elements of Ratings1 will be the same as the Ratings, but im just trying figure this part out. Thanks- Hide quoted text - - Show quoted text - I guess i am just trying to create a new array with old array elements, but i see your point however i am using redim preserve and not just redim. I want to create array Ratings1 from Ratings. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Aug 22, 9:08 am, "Peter T" <peter_t@discussions wrote:
not just redim. I want to create array Ratings1 from Ratings. If you mean copy Ratings to Ratings1, simply Ratings1 = Ratings Ratings may have been declared as an array but .... Dim Ratings1 as Variant Regards, Peter T wrote in message ups.com... On Aug 22, 8:38 am, "Bob Phillips" wrote: What are you trying to do? You setup a loop to look through each cell in Ratings, then ignore the value obtained each time. You redim your array each iteration of the loop, thereby losing data each time. etc. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message roups.com... I am looking to create a new array with elements of a previously created array. Whe For Each cell In Ratings ReDim Preserve Ratings1(6, rw) Ratings1(0, rw) = Ratings(0, rw) Ratings1(1, rw) = Ratings(1, rw) Ratings1(2, rw) = Ratings(2, rw) Ratings1(3, rw) = Ratings(3, rw) Ratings1(4, rw) = Ratings(4, rw) Ratings1(5, rw) = Ratings(5, rw) rw = rw - 1 Next Cell "Ratings" is my old array and "Ratings1" is my new array that i am creating. "Ratings" is in the same sub and will have the same number of row elements. For some reason this is not working. When im done not all elements of Ratings1 will be the same as the Ratings, but im just trying figure this part out. Thanks- Hide quoted text - - Show quoted text - I guess i am just trying to create a new array with old array elements, but i see your point however i am using redim preserve and not just redim. I want to create array Ratings1 from Ratings.- Hide quoted text - - Show quoted text - Thanks, but in reality i want to have some rows of the new array to be different values, i was more just looking for the reason that i couldn't just assign elements of the old array to elements of the new array by saying that for example Ratings1(1, 5) = Ratings(1,5). For some reason this is not working. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Then maybe either array doesn't have that particular element.
How is Ratings populated, and where does rw get set? -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message ps.com... On Aug 22, 9:08 am, "Peter T" <peter_t@discussions wrote: not just redim. I want to create array Ratings1 from Ratings. If you mean copy Ratings to Ratings1, simply Ratings1 = Ratings Ratings may have been declared as an array but .... Dim Ratings1 as Variant Regards, Peter T wrote in message ups.com... On Aug 22, 8:38 am, "Bob Phillips" wrote: What are you trying to do? You setup a loop to look through each cell in Ratings, then ignore the value obtained each time. You redim your array each iteration of the loop, thereby losing data each time. etc. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message roups.com... I am looking to create a new array with elements of a previously created array. Whe For Each cell In Ratings ReDim Preserve Ratings1(6, rw) Ratings1(0, rw) = Ratings(0, rw) Ratings1(1, rw) = Ratings(1, rw) Ratings1(2, rw) = Ratings(2, rw) Ratings1(3, rw) = Ratings(3, rw) Ratings1(4, rw) = Ratings(4, rw) Ratings1(5, rw) = Ratings(5, rw) rw = rw - 1 Next Cell "Ratings" is my old array and "Ratings1" is my new array that i am creating. "Ratings" is in the same sub and will have the same number of row elements. For some reason this is not working. When im done not all elements of Ratings1 will be the same as the Ratings, but im just trying figure this part out. Thanks- Hide quoted text - - Show quoted text - I guess i am just trying to create a new array with old array elements, but i see your point however i am using redim preserve and not just redim. I want to create array Ratings1 from Ratings.- Hide quoted text - - Show quoted text - Thanks, but in reality i want to have some rows of the new array to be different values, i was more just looking for the reason that i couldn't just assign elements of the old array to elements of the new array by saying that for example Ratings1(1, 5) = Ratings(1,5). For some reason this is not working. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry I don't follow what you are trying to do
Ratings1(1, 5) = Ratings(1,5). Providing each array is sized to accommodate (1,5), and Ratings1 can accept similar data type to that in Ratings(1,5), the above will work Regards, Peter T <snip I guess i am just trying to create a new array with old array elements, but i see your point however i am using redim preserve and not just redim. I want to create array Ratings1 from Ratings.- Hide quoted text - Thanks, but in reality i want to have some rows of the new array to be different values, i was more just looking for the reason that i couldn't just assign elements of the old array to elements of the new array by saying that for example Ratings1(1, 5) = Ratings(1,5). For some reason this is not working. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use formulas for array elements | Excel Discussion (Misc queries) | |||
array elements count | Excel Programming | |||
Reference Elements w/in an Array | Excel Discussion (Misc queries) | |||
Non-unique elements in an array | Excel Discussion (Misc queries) | |||
Number of elements in an array | Excel Programming |