Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Carlo,
Whilst this function will work without side effects when called from the worksheet, if called from code the variable supplied to fill the Space_Text argument will be changed, as you are passing by reference. If this is not intended, you should change the signature to read ...ByVal Space_Text As String,..., or use a TempStr Check out "ByVal" and "ByRef" in the Help if in doubt. NickHK "Carlo" ... Hi Nick Thanks a lot for your answer, the same approach i started after posting this thread :) i did it without a tempstring: '----------------------------------------- Function InsChr(Space_Text As String, Character As String) As String For i = 1 To Len(Space_Text) Space_Text = Mid(Space_Text, 1, (i - 1) * 2 + 1) & Character & Mid(Space_Text, i * 2) Next i InsSpace = Left(Space_Text, Len(Space_Text) - 1) End Function '----------------------------------------- Embedded Spaces will be treated as characters. Thanks for your time Cheers Carlo "NickHK" wrote: Carlo, Something like this : Public Function InsertSpacesInText(argInput As Variant) As String Dim i As Long Dim Tempstr As String For i = 1 To Len(argInput) Tempstr = Tempstr & Mid(argInput, i, 1) & " " Next 'remove last SPACE InsertSpacesInText = Left(Tempstr, Len(Tempstr) - 1) End Function You should add code for dealing with embedded spaces if required. NickHK "Carlo" wrote in message ... Hi all i'm trying to split a text, actually a real easy task, excel provides the split function! But what if I want Excel to use each character as a substring?? i.e. "Hello" == "H","e","l","l","o" Is this possible? I want to make a function which returns me a string, with a space between every character: "Hello" == "H e l l o" If I could split up the string, i could join it again, and put a space between each character. Possibly there's another / better solution for my problem, if so, i would be real glad if you could tell me :) Thanks a lot for everything Cheers Carlo |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text Split | New Users to Excel | |||
Split a text | Excel Worksheet Functions | |||
Split text without using data-text to columns | Excel Discussion (Misc queries) | |||
Split Text | Excel Discussion (Misc queries) | |||
text cells end page how split to next. Text lost! | Excel Discussion (Misc queries) |