Question Worksheet_Change Event

sadath

Active Member
Joined
Oct 10, 2004
Messages
267
Office Version
  1. 365
Platform
  1. Windows
I have following code on a sheet, but it executes continuesly & stucks

My aim is, if I enter 12 shoul display 12000

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Value = Target.Value * 1000
End Sub
 

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.
I think it's because every time it changes the value it retriggers the event.

Try:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
 Target.Value = Target.Value * 1000
Application.EnableEvents = True

End Sub
I think this should solve it.
 
Last edited:
Upvote 0
You're changing the worksheet inside the Worksheet_Change event, so it will trigger itself again. And again. And again. And again. And again. And again. And again. And again. And again. And again...

Try this:-
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Application.EnableEvents=False
  Target.Value = Target.Value * 1000
  Application.EnableEvents=True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,538
Messages
6,179,412
Members
452,912
Latest member
alicemil

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