Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
why is it when i use this:
Function cvText(cllText As String) For i = 1 To Len(cllText) cvText = Mid(cllText, i, 1) Next End Function .... and test it.. Print cvText("hello") o I get "o" but if I use Function cvText(cllText As String) For i = 1 To Len(cllText) cvText = Right(clltext,i) Next End Function i get: Print cvText("hello") hello i get "hello" i want to be able to loop through each character using mid(clltext,i,1) to test if there is a blank. the goal is to create a function that ucase's the beginning of each letter of a word thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Vincent,
The function return value is whatever the last thing is that you assigned to the function name. In the first case it was the last letter of the input, in the second case it was all the letters of the input. I've modified the first function below to return the entire input string: Function cvText(cllText As String) Dim i As Long For i = 1 To Len(cllText) cvText = cvText & Mid(cllText, i, 1) Next i End Function Note that with each pass through the loop the additional character is being concatenated onto the previous characters, rather than replacing them as in the original. -- Rob Bovey, MCSE, MCSD, Excel MVP Application Professionals http://www.appspro.com/ * Please post all replies to this newsgroup * * I delete all unsolicited e-mail responses * "vincentj" wrote in message ... why is it when i use this: Function cvText(cllText As String) For i = 1 To Len(cllText) cvText = Mid(cllText, i, 1) Next End Function ... and test it.. Print cvText("hello") o I get "o" but if I use Function cvText(cllText As String) For i = 1 To Len(cllText) cvText = Right(clltext,i) Next End Function i get: Print cvText("hello") hello i get "hello" i want to be able to loop through each character using mid(clltext,i,1) to test if there is a blank. the goal is to create a function that ucase's the beginning of each letter of a word thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF statement inside a SUMIF statement.... or alternative method | Excel Worksheet Functions | |||
Reconcile Bank statement & Credit card statement & accounting data | Excel Worksheet Functions | |||
Embedding an OR statement in an IF statement efficiently | Excel Discussion (Misc queries) | |||
Sum if statement with a left statement | Excel Discussion (Misc queries) | |||
appending and IF statement to an existing IF statement | Excel Worksheet Functions |