Private Sub Ucase Stopped working

rickadams

New Member
Joined
Feb 11, 2018
Messages
32
Hi,

For dyslexic people like me reading text that is mixed case is difficult so I found this script that was working great.
All of a sudden the script saved in my sheet(s) stopped working, on my main computer. When running on other computers the script still works.
I received an error after deleting some cells.
I closed and restarted Excel 2010 and now it will not work at all.
I do not think I changed any settings, however if I did which one would stop Private from Working?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End Sub
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Are you sure you completely restarted Excel and didn't just reopen the workbook?
 
Upvote 0
I received an error after deleting some cells.
That will continue to happen if you delete multiple cells at once or paste multiple cells at once. I would suggest the following change to avoid that
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim c As Range
  
  Application.EnableEvents = False
  For Each c In Target
    c.Value = UCase(c.Value)
  Next c
  Application.EnableEvents = True
End Sub
 
Upvote 0
Thank you for responding, I shut down the computer (windows did its usual update thing) and the script still did not work. Peter_SS posted a solution, and that worked for me. This only happened on 1 computer. And I think I am good now...
 
Upvote 0
Thank you for responding, I shut down the computer (windows did its usual update thing) and the script still did not work. Peter_SS posted a solution, and that worked for me. This only happened on 1 computer. And I think I am good now...
My suggestion was not related to your code "not working at all". The code could have "stopped working at all" when you got the error message deleting multiple cells because 'events' may have been left disabled. The suggestion of Rory's was one way to get your events re-enabled. Anyway, it seems like you have got to that point somehow.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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