• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VB Macro - Change Case

manoj_th

Member
Hello Sirs,


I need a VB macro to change the text from lower case to upper case automatically.

Eg : If I enter "t" in cell "C5" it should get change to "T".

I need to a particular range like "C$2:C$100".


Regards,

Manoj
 
Manoj

Try the following code

Copy it to a Sheet Module for the worksheet you want it to apply to in VBA

not a Code Module

[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C$2:C$100")) Is Nothing Then Exit Sub
Target = UCase(Target)
End Sub
[/pre]
 
Don't forget to turn off events first, so that you don't cause the Event macro to run over and over (since it keeps changing the worksheet, macro keeps getting called)

[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C$2:C$100")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True
End Sub
[/pre]
 
Back
Top