Change to UPPER Case

Steve 1962

Active Member
Joined
Jan 3, 2006
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Hi

Could someone tell me what VBA code to use in order to have all entries in cells A3 to A5003 be automatically entered as UPPER case ?

Thanks

SH
 
Sorry...using the quoted code...

Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A3:A5003")) Is Nothing Then
    Application.EnableEvents = False
    Target.Value = UCase(Target.Value)
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C3:C5000")) Is Nothing And Target.Offset(, 1).Value = "Client" Then
    Application.EnableEvents = False
    Target.Value = UCase(Target.Value)
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
It works fine ie. if I enter each cell with F2 and hit enter it converts all the existing clients to upper case. However, I run two macros to insert a row for a new contact or one that is existng i.e. Client or Supplier etc. and it gives me an eror on the first bit of code. One macro enters all new blank cells while the other duplicates an existing company and leaves information like company name, address etc and removes such things as names and personal information.
 
Upvote 0
Also, the column for the client etc is in D and the name of the client is in C. I see it is in the wrong position and the form is used by several departments so cannot move it to show before the client name... Does this knock this out of the question?
 
Upvote 0
Hello Peter,

I took a look at where all the workbooks go to and believe that I can reverse so that the Contact type i.e. Client, Employee etc can come before the company name i.e. reverse D with C. Does that help?
 
Upvote 0
Perhaps

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D3:D5000")) Is Nothing And Target.Offset(, -1).Value = "Client" Then
    Application.EnableEvents = False
    Target.Value = UCase(Target.Value)
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Thanks a lot Peter. The code works fine but it continues to get a run-time error 1004 every time a row is added or deleted and returns Application-defined or object-defined error.
 
Upvote 0
Try this

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("D3:D5000")) Is Nothing And Target.Offset(, -1).Value = "Client" Then
    Application.EnableEvents = False
    Target.Value = UCase(Target.Value)
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Thanks very much Peter! That works perfectly! I really appreciate all your help on this.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top