View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Convert string to variable

maybe...

..Cells(i, "A") = Sheets("words").Cells(RandRow + i, "A")

& is usually used to concatenate strings: "Jason" & " " & "Morin"
+ is used to add numbers

(Excel sometimes allows + with strings, too. But it's better to be safe.)

Jason Morin wrote:

I have several variables named RandRow1, RandRow2, etc. that have been
populated with values. How do I convert a concatenated string into an actual
variable? In this case it's RandRow & i where i = 1 to 10. Thanks.

Dim RandRow1 as Long
Dim RandRow2 as Long
etc.

With Sheets("writtentest")
For i = 1 To 10
.Cells(i, "A") = Sheets("words").Cells(RandRow & i, "A")
Next
End With


--

Dave Peterson