David
I think your syntax should be;
Sub tester()
Dim VARIABLE
VARIABLE = (InputBox("Prompt", "Title"))
VARIABLE = Format(VARIABLE, ">")
End Sub
Ivan
Thankyou, this worked
Regards
David
Re: Thanks for Your Help => is there a way to do this only to 1st Letter of each word
Hi,
Sorry i thought I was finished but I need a way to only captilize the first letter of each word.
Re: Thanks for Your Help => is there a way to do this only to 1st Letter of each word
Hi David try this
Sub Tester()
Dim VARIABLE As String
Dim TempText As String
Dim x As Integer
Dim Holder() As String
Dim CapNext As Boolean
'\\\\\\\\\\\\ ROUTINE TO CAPITILISE 1ST LETTER OF INPUT \\\\\\\\\\\
' \
' DONE FOR DAVID 12/04/2000 \
' \
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
VARIABLE = (InputBox("Prompt", "Title"))
ReDim Holder(Len(VARIABLE))
For x = 1 To Len(VARIABLE)
'Check 1st letter
TempText = Mid(VARIABLE, x, 1)
'Test 1st position of string
If x = 1 And TempText <> " " Then TempText = Format(Mid(VARIABLE, x, 1), ">")
'Anything after a space should be Capitilised
If TempText = " " Then
CapNext = True
ElseIf CapNext Then TempText = Format(Mid(VARIABLE, x, 1), ">"): CapNext = False
End If
'Assign to seperate Holding variable
Holder(x) = TempText
Holder(0) = Holder(0) & Holder(x)
Next
VARIABLE = Holder(0)
'msg to test
MsgBox VARIABLE
End Sub
Ivan
David
As you are renaming your worksheets you should
have (if you don't already have it) an error checking routine. Try this one.
Sub Tester()
Dim VARIABLE As String
Dim TempText As String
Dim x As Integer
Dim Holder() As String
Dim CapNext As Boolean
Dim TryAgain As Integer
'\\\\\\\\\\\\ ROUTINE TO CAPITILISE 1ST LETTER OF INPUT \\\\\\\\\\\
' \
' DONE FOR DAVID 12/04/2000 \
' \
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Again: VARIABLE = (InputBox("Prompt", "Title"))
If VARIABLE = "" Then End
ReDim Holder(Len(VARIABLE))
For x = 1 To Len(VARIABLE)
'Check 1st letter
TempText = Mid(VARIABLE, x, 1)
'Test 1st position of string
If x = 1 And TempText <> " " Then TempText = Format(Mid(VARIABLE, x, 1), ">")
'Anything after a space should be Capitilised
If TempText = " " Then
CapNext = True
ElseIf CapNext Then TempText = Format(Mid(VARIABLE, x, 1), ">"): CapNext = False
End If
'Assign to seperate Holding variable
Holder(x) = TempText
Holder(0) = Holder(0) & Holder(x)
Next
VARIABLE = Holder(0)
'msg to test
MsgBox VARIABLE
On Error GoTo ErrH
ActiveSheet.Name = VARIABLE
Exit Sub
ErrH:
TryAgain = MsgBox("Error#: " & Err.Number & Chr(13) & "Error msg: " & Err.Description & Chr(13) _
& Chr(13) & Chr(13) & "Do you want to try again?", vbCritical + vbYesNo, "Rename sheet Error")
If TryAgain <> vbYes Then End
GoTo Again
End Sub
Ivan