ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing Variable length Space Characters to Variables (https://www.excelbanter.com/excel-programming/352705-passing-variable-length-space-characters-variables.html)

ExcelMonkey

Passing Variable length Space Characters to Variables
 
How do you pass variable length space to a variable. If I want to pass a
space cwith three spaces, I can do it manually by going:

Var = "---" (dashes representing spaces)

But what if the space width is variable in length? In this example I need
to pass the number three to a variable and then use this to define the space
between my quotes that get passed to my Var.

Thanks

tony h[_58_]

Passing Variable length Space Characters to Variables
 

var=String(3, "-")

regards


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=509596


Jim Thomlinson[_5_]

Passing Variable length Space Characters to Variables
 
There is a function called string which takes two arguments. The number of
charachters and the character to repeat.

dim myString as String

myString = String(3, "-")
msgbox myString 'Shows 3 dashes

Just as a note I have always disliked the fact that String is both a data
type and a function. Who thought of that...
--
HTH...

Jim Thomlinson


"ExcelMonkey" wrote:

How do you pass variable length space to a variable. If I want to pass a
space cwith three spaces, I can do it manually by going:

Var = "---" (dashes representing spaces)

But what if the space width is variable in length? In this example I need
to pass the number three to a variable and then use this to define the space
between my quotes that get passed to my Var.

Thanks


ExcelMonkey

Passing Variable length Space Characters to Variables
 
Figured it out. Thanks

DesiredLenth = 3
SpaceWidth = ""
For Y = 1 To DesiredLenth
SpaceWidth = SpaceWidth & Chr(32)
Next
CurrentFormulaNoFunction = Replace(CurrentFormula, AllFunctions(X),
SpaceWidth, 1, -1, vbTextCompare)




"ExcelMonkey" wrote:

How do you pass variable length space to a variable. If I want to pass a
space cwith three spaces, I can do it manually by going:

Var = "---" (dashes representing spaces)

But what if the space width is variable in length? In this example I need
to pass the number three to a variable and then use this to define the space
between my quotes that get passed to my Var.

Thanks


Robin Hammond[_2_]

Passing Variable length Space Characters to Variables
 
Does this help?

Sub Test()
Dim strData As String
strData = Space(50)
Debug.Print Len(strData)
Debug.Print strData & "x"
End Sub

Robin Hammond
www.enhanceddatasystems.com

"ExcelMonkey" wrote in message
...
How do you pass variable length space to a variable. If I want to pass a
space cwith three spaces, I can do it manually by going:

Var = "---" (dashes representing spaces)

But what if the space width is variable in length? In this example I need
to pass the number three to a variable and then use this to define the
space
between my quotes that get passed to my Var.

Thanks




Dana DeLouis

Passing Variable length Space Characters to Variables
 
But what if the space width is variable in length?

Just one example:

Sub Demo()
Dim n, Str
n = 10
Str = Space(n)
End Sub

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"ExcelMonkey" wrote in message
...
How do you pass variable length space to a variable. If I want to pass a
space cwith three spaces, I can do it manually by going:

Var = "---" (dashes representing spaces)

But what if the space width is variable in length? In this example I need
to pass the number three to a variable and then use this to define the
space
between my quotes that get passed to my Var.

Thanks





All times are GMT +1. The time now is 09:15 AM.

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