![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 13
|
Can I use varaible as part of a variable name? For example, using looping actions, the procedure returns Weight (an integer variable) from row 2, then cycles through the remaining roews and returns additional Weight values. Each time thourgh the loop, I want to assign the returned value to a variable. The variable will be Weightk. The k represents the counting variable in the looping action. So the first returned value becomes Weight1, the second returned value becomes Weight2, etc.
I have attempted Weight & k = Weight but get Compile error: expected expression as well as other forms. Any ideas? |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
You could use an array, for example-
WeightArray(k) = Weight Loop back through the array at the end to return your values. [ This Message was edited by: Mudface on 2002-02-28 08:29 ] |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
You can use an array:
Code:
Dim aintWeight(2 to 20) as Integer
Dim intRow as Integer
For intRow = 2 to 20
aintWeight(intRow) = Cells(intRow, 3)
Next intRow
' Assumes weight values in column C
' ...
Russell |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|