Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for taking the time to read my question
I would like add a space to my string x times, where x = an integer. How can I do that with out using a loop statement? x=10 eg: "there are 10 spaces between here" & space * x & "here." Thanks, Brad |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There is a function called space that you could use
dim str as string str = "this" & space(10) & "that" -- HTH... Jim Thomlinson "Brad" wrote: Thanks for taking the time to read my question I would like add a space to my string x times, where x = an integer. How can I do that with out using a loop statement? x=10 eg: "there are 10 spaces between here" & space * x & "here." Thanks, Brad |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just to add to Jim's reply...
There's another function that can be used with other non-space characters: dim str as string str = String(12, "x") (It can also be used with space characters <bg.) Jim Thomlinson wrote: There is a function called space that you could use dim str as string str = "this" & space(10) & "that" -- HTH... Jim Thomlinson "Brad" wrote: Thanks for taking the time to read my question I would like add a space to my string x times, where x = an integer. How can I do that with out using a loop statement? x=10 eg: "there are 10 spaces between here" & space * x & "here." Thanks, Brad -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yeah but I loved the ironly that Brad had the function correct and that the
only error was *x instead of (x). -- HTH... Jim Thomlinson "Dave Peterson" wrote: Just to add to Jim's reply... There's another function that can be used with other non-space characters: dim str as string str = String(12, "x") (It can also be used with space characters <bg.) Jim Thomlinson wrote: There is a function called space that you could use dim str as string str = "this" & space(10) & "that" -- HTH... Jim Thomlinson "Brad" wrote: Thanks for taking the time to read my question I would like add a space to my string x times, where x = an integer. How can I do that with out using a loop statement? x=10 eg: "there are 10 spaces between here" & space * x & "here." Thanks, Brad -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
And just to add onto Dave reply, the String function only repeats single
characters; however, if you wanted to repeat multiple characters, all you would have to do is couple the String or Space function with the Replace function. For example, to produce a text string of, say, 100 "XO" character pairs in a row, just do this... HundredXOs = Replace(Space(100), " ", "XO") or this would work also... HundredXOs = Replace(String(100, "Z"), "Z", "XO") where you can use any character you want to in place of the "Z". -- Rick (MVP - Excel) "Dave Peterson" wrote in message ... Just to add to Jim's reply... There's another function that can be used with other non-space characters: dim str as string str = String(12, "x") (It can also be used with space characters <bg.) Jim Thomlinson wrote: There is a function called space that you could use dim str as string str = "this" & space(10) & "that" -- HTH... Jim Thomlinson "Brad" wrote: Thanks for taking the time to read my question I would like add a space to my string x times, where x = an integer. How can I do that with out using a loop statement? x=10 eg: "there are 10 spaces between here" & space * x & "here." Thanks, Brad -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
this adds 10 spaces to the end without a loop and with the use of left/mid/right you could put the spaces anywhere x = 10 mystring = "Mike H" mystring = mystring + WorksheetFunction.Rept(" ", x) Mike "Brad" wrote: Thanks for taking the time to read my question I would like add a space to my string x times, where x = an integer. How can I do that with out using a loop statement? x=10 eg: "there are 10 spaces between here" & space * x & "here." Thanks, Brad |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks to all for your posts!!
It is quite ironic that I was so close but yet had no idea. Hope everyone has a great day today, Brad "Brad" wrote: Thanks for taking the time to read my question I would like add a space to my string x times, where x = an integer. How can I do that with out using a loop statement? x=10 eg: "there are 10 spaces between here" & space * x & "here." Thanks, Brad |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Repeat a macro until the last line is empty or repeat it 1400 time | Excel Programming | |||
Repeat keystrokes to delete character in column | Excel Worksheet Functions | |||
How do I repeat a character in a cell in Excel as / did in Lotus? | Excel Discussion (Misc queries) | |||
importing undelimited text file data, character-by-character | Excel Programming | |||
Title Cut Off if Rows to Repeat & Columns to Repeat are Both Selec | Excel Discussion (Misc queries) |