Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert case to upper case

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I am trying to force upper case letters to be entered into my input box I tried a couple of methods with no luck. I am hoping that someone can help me. I get an error 438 when I run the code
Code:
Dim myNum5 As String
myNum5 = Application.InputBox("Enter Time Charge  ex. PAQ-000")

Range("M" & LR - 3).Value = (myNum5)
    With Selection
    .vbUpperCase
    .Columns.AutoFit
    .VerticalAlignment = xlCenter
    .HorizontalAlignment = xlRight
    End With
 
Hi vba317,

It's not clear tome whether you're trying to change the case of the data entered via the InputBox, or of the selected cell(s), which may be different. Here's some mods to the code to do both:
Code:
Dim oCel As Range
Dim myNum5 As String
myNum5 = Application.InputBox("Enter Time Charge  ex. PAQ-000")
Range("M" & LR - 3).Value = UCase((myNum5))
For Each oCel In Selection.Cells
  With oCel
    .Value = UCase(.Text)
    .VerticalAlignment = xlCenter
    .HorizontalAlignment = xlRight
  End With
Next
Selection.Columns.AutoFit
You can choose which part you want to use. Note that I've changed where the Autofit occurrs too - that avoids the unpredicatle results you could get by iteratively autofitting to each cell in a multi-cell selection.


Cheers
[MS MVP - Word]
 
Assuming that Selection is same ss Range("M" & LR - 3):
Code:
Dim myNum5 As String
myNum5 = Application.InputBox("Enter Time Charge  ex. PAQ-000")

With Range("M" & LR - 3)
    .Value = StrConv(myNum5, vbUpperCase)
    .Columns.AutoFit
    .VerticalAlignment = xlCenter
    .HorizontalAlignment = xlRight
End With
However, this code does not pick keyboard convert input directly in the input box. To proceed this way, a custom form should be designed.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top