Drop down list value sets off a macro but wont let me go back and change the value in the drop down list

Darkshine

New Member
Joined
Jul 3, 2018
Messages
13
Good morning folks.

Wonderful to be part of this community.

I was hoping someone could answer my question.

I have a list of values (3) in cell P53 of a worksheet. When "Yes - Full" is the active selection from that list, a macro runs which essentially makes sure there is a formula in cell Q53. The problem I am having is, if I now choose to go back to cell P53 to change the value, it won't let me. It seems to immediately run the macro again. What do I need to add to my code to avoid this issue?

my code is thus:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Value = "Yes - Full" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
Call pension1
Application.EnableEvents = True
Application.ScreenUpdating = True
Else
End If
End Sub

Thank you in advance kind and brainy people!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,

Try putting your code in Worksheet_Change event rather than Worksheet_SelectionChange.
 
Upvote 0
Have the code change or clear the cell value.

Code:
[COLOR=#333333]Private Sub Worksheet_SelectionChange(ByVal Target As Range)[/COLOR]
[COLOR=#333333]If Target.Value = "Yes - Full" Then[/COLOR]
[COLOR=#333333]Application.EnableEvents = False[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = False[/COLOR]
[COLOR=#333333]Call pension1
[/COLOR][B]Target.Value = ""[/B]
[COLOR=#333333]Application.EnableEvents = True[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = True[/COLOR]
[COLOR=#333333]Else[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
Upvote 0
Thanks for your reply.

Now you're going to think I'm stupid.

I originally had my code in there but I have another private sub in there and the two wouldn't work together.

I was getting an ambiguous name error.

which part of the code would I need to change for that error not to occur?

Thanks.
 
Upvote 0
Have the code change or clear the cell value.

Code:
[COLOR=#333333]Private Sub Worksheet_SelectionChange(ByVal Target As Range)[/COLOR]
[COLOR=#333333]If Target.Value = "Yes - Full" Then[/COLOR]
[COLOR=#333333]Application.EnableEvents = False[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = False[/COLOR]
[COLOR=#333333]Call pension1
[/COLOR][B]Target.Value = ""[/B]
[COLOR=#333333]Application.EnableEvents = True[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = True[/COLOR]
[COLOR=#333333]Else[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]End Sub[/COLOR]

I need the value to remain, so that doesn't work for me, sorry.
 
Upvote 0
Show us your other worksheet_change event code and someone can help you combine it with the one you posted which needs to be revised to a worksheet_change event.
 
Upvote 0
Show us your other worksheet_change event code and someone can help you combine it with the one you posted which needs to be revised to a worksheet_change event.


Private Sub Worksheet_Change(ByVal t As Range)
If Not Intersect(t, Range("c14,c17,c20,c23")) Is Nothing Then
If t.Value > 1600000 Then
MsgBox "The Allowable TSB Limit of $1,600,000.00 has been breached", beepnow()
End If
End If
End Sub

thanks for your help on this
 
Upvote 0
Private Sub Worksheet_Change(ByVal t As Range)
If Not Intersect(t, Range("c14,c17,c20,c23")) Is Nothing Then
If t.Value > 1600000 Then
MsgBox "The Allowable TSB Limit of $1,600,000.00 has been breached", beepnow()
End If
End If
End Sub

thanks for your help on this
What range do you want to monitor for the "Yes - Full" change event?
 
Upvote 0

also... if P44 = "Yes - full" then macro to save a different formula to Q54
also... if P45 = "Yes - full" then macro to save a different formula to Q55
also... if P46 = "Yes - full" then macro to save a different formula to Q56

does that make sense?
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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