LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Split Text

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text Split DDay New Users to Excel 4 May 14th 09 02:39 PM
Split a text Manos Excel Worksheet Functions 7 October 17th 07 05:51 PM
Split text without using data-text to columns Jambruins Excel Discussion (Misc queries) 7 January 21st 06 02:16 PM
Split Text Gabe Excel Discussion (Misc queries) 6 January 4th 06 09:52 PM
text cells end page how split to next. Text lost! Elaine Excel Discussion (Misc queries) 1 August 28th 05 05:48 PM


All times are GMT +1. The time now is 05:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"