For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > December 2005 > variable in string...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author variable in string...
ivan

2005-12-14, 6:57 pm

hi... i'm a super newbie in this... but i'd really appreciate it if anyone
could help me here...
i'm trying to write a simple macro for excel, which goes something like
this...

for help = 10 to 50
y = 10
cells(help,y).value = " '4help2"
next help

how do i make the cells' values '4102 to '4502 instead of '4help2 ?

really appreciate it... thanks


Veign

2005-12-14, 6:57 pm

"4" & Cstr(help) & "2"

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
Veign's Blog
http://www.veign.com/blog
--


"ivan" <ivanxiao@hotmail.com> wrote in message
news:O6jZAnNAGHA.3048@TK2MSFTNGP15.phx.gbl...
> hi... i'm a super newbie in this... but i'd really appreciate it if anyone
> could help me here...
> i'm trying to write a simple macro for excel, which goes something like
> this...
>
> for help = 10 to 50
> y = 10
> cells(help,y).value = " '4help2"
> next help
>
> how do i make the cells' values '4102 to '4502 instead of '4help2 ?
>
> really appreciate it... thanks
>



Ken Halter

2005-12-14, 6:57 pm

"ivan" <ivanxiao@hotmail.com> wrote in message
news:O6jZAnNAGHA.3048@TK2MSFTNGP15.phx.gbl...
> hi... i'm a super newbie in this... but i'd really appreciate it if anyone
> could help me here...
> i'm trying to write a simple macro for excel, which goes something like
> this...
>
> for help = 10 to 50
> y = 10
> cells(help,y).value = " '4help2"
> next help
>
> how do i make the cells' values '4102 to '4502 instead of '4help2 ?
>
> really appreciate it... thanks


Is something like this what you're after?
'=========
Private Sub Command1_Click()
'how do i make the cells' values '4102 to '4502 instead of '4help2 ?
Dim help As Integer
Dim y As Integer
Dim sCellContents As String

y = 10
For help = 10 To 50 Step 10
sCellContents = "4" & help & "2"
Debug.Print sCellContents
Next help

'Debug.Print shows:
'4102
'4202
'4302
'4402
'4502
End Sub
'=========

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com