View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default In A macro create a string of variables as needed

I know this can be done. Probably using an array. I'll work on it tomorrow.
right now I can hardly hold my eyes open.

"D. Jones" wrote:

Thank you for the response but I haven't defined my question clearly. I want
to store many different values each with a different (unique) variable anme
so that when I write the code to paste the values into cells I have all the
values stored. I write from one sheet to another many times and do not want
to switch between the sheets after each loop. So i would have values for
myvar1, myvar2, myvar3 as many times as I have satisfied my do until and if
statments within the "loop" statement. The number of variables will change
depsneding on the matcheds found.

"JLGWhiz" wrote:

I know better than that. Use this one.

Sub chngVarVal()
For i = 1 To 5
If Cells(i, 1) < ABC Then
myVar = Cells(i, 2)
c.Offset(0, 5) = myVar
End If
Next
End Sub

"D. Jones" wrote:

Is it possible to program a variable (new name) for each occurance required
during a loop statement.

For example can we make a variabe = to a cell value and then on the next
pass change teh varialbe by the count ot save another cell value to this new
variable name. ie. "AMT1" for the first scan and cell value that matches
criteria programed and tehn on the next loop the varialbe can be named "AMT2"
and so on and so on?