Force Value to Upper Case Visual Basic Excel Macro

Your rating: None Average: 1 (2 votes)

The below Visual Basic code is used in an excel macro. It reads the values on Row "R", trim spaces, checks if the length of the value is equal to zero (nothing in that cell). If so the it will output the letter "N" otherwise it will output an upper case value entered by the user (Format(UCase((ActiveCell.Value))).

The "!@" is the VB way in saying you want to output one character. So, if you have a cell that has 8 character you would code "!@@@@@@@@"

ActiveSheet.Range("R" + posrow).Activate
ActiveCell.Value = Left(Trim(ActiveCell.Value), 1)
If (Len(Trim(ActiveCell.Value)) = 0) Then
   Out_Record = Out_Record + "N"
   Out_Record = Out_Record + Format(UCase((ActiveCell.Value)), "!@")
End If

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!


Have a question? Please ask it on the forum instead.
Guest's picture
Guest (not verified)
Help with VB 6.0 (UPPERCASE)

hi, i want to input data by textbox in vb 6.0 but in UPPERCASE only.
would you like to help me


CompShack's picture
User offline. Last seen 7 years 17 weeks ago. Offline
Joined: 12/09/2007
Posts: 167

I'm not a VB guy by any means. The example i have is using an excel macro to force an upper case output. I'm sorry but I wouldn't be able to help on this one :(

I did a quick google search and got lots of good info but wasn't sure what you are really looking for. Please re-visit the site and post your solution when you find one. I would greatly appreciate it.

Good luck!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Peter Chiu's picture
Peter Chiu (not verified)
Re: Force Value to Upper Case Visual Basic Excel Macro

Private Sub {TextBox Name}_Change()
{TextBox Name} = UCase({TextBox Name})
End Sub

Replace {TextBox Name} with the Name of the textbox you want all upper case.

Guest's picture
Guest (not verified)
Re: Force Value to Upper Case Visual Basic Excel Macro

Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.