Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Convert string to variable

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable string$ Ferdy New Users to Excel 3 November 26th 08 08:45 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
How do I convert an integer variable to a string variable? dumbass Excel Programming 2 May 21st 04 07:34 PM
Join string with variable name to get variable value Dianne Excel Programming 6 February 12th 04 04:24 AM
VBA - Convert my variable range array to single cell string Kevin G[_2_] Excel Programming 6 January 28th 04 07:20 AM


All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"