View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
moon[_7_] moon[_7_] is offline
external usenet poster
 
Posts: 53
Default Convert string to variable


Public Sub Test123()

Dim rng As String
Dim x, y As Integer

x = 1: y = 8

'Construction of string -- A1:E8
rng = "A" & LTrim(Str(x)) & ":E" & LTrim(Str(y))

ActiveSheet.Range(rng).Select

End Sub





"Jason Morin" schreef in bericht
...
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