ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with string functions (https://www.excelbanter.com/excel-programming/292512-help-string-functions.html)

margie[_6_]

help with string functions
 
I need some help with string functions. Let's say I have a set o
numbers from 1 to n. (1,2,3,4,...n). the user will input what th
value of n will be. the program will then create the string of number
from 1 to n. I've been playing around with the mid function but tha
requires an initial defined string. Is there any way to create thi
string of numbers without an initial defined string?

example:

user defines n=9

string = 123456789

thanks

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

help with string functions
 
Hi Margie,

Try this

For i = 1 to n
myString = myString & i
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"margie " wrote in message
...
I need some help with string functions. Let's say I have a set of
numbers from 1 to n. (1,2,3,4,...n). the user will input what the
value of n will be. the program will then create the string of numbers
from 1 to n. I've been playing around with the mid function but that
requires an initial defined string. Is there any way to create this
string of numbers without an initial defined string?

example:

user defines n=9

string = 123456789

thanks.


---
Message posted from http://www.ExcelForum.com/




Jim Cone

help with string functions
 
margie,

Here is one way...

'------------------------------
Sub MakeNumbers()
Dim strNumbers As String
Dim lngNum As Long
Dim lngCounter As Long

'A limit should be placed on the value of lngNum
'Also, check to make sure that a numeric value was entered
lngNum = 99

For lngCounter = 1 To lngNum
strNumbers = strNumbers & CStr(lngCounter)
Next
MsgBox strNumbers
End Sub
'------------------------------

Regards,
Jim Cone
San Francisco, CA

"margie " wrote in message
...
I need some help with string functions. Let's say I have a set of
numbers from 1 to n. (1,2,3,4,...n). the user will input what the
value of n will be. the program will then create the string of numbers
from 1 to n. I've been playing around with the mid function but that
requires an initial defined string. Is there any way to create this
string of numbers without an initial defined string?
example:
user defines n=9
string = 123456789
thanks.





All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com