Drop down list to return to default after selecting from drop down

NYJets44

New Member
Joined
Jan 10, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hi all, I need some help returning the original default after selecting another option from a drop down list. AM8 and AX8 both have FY22 and FY23 in their drop down lists. However, I set up the code to run a macro whenever you make a selection of FY22 or FY23. I would like for the list to return to the original default that was set even after selecting a different option from the drop down. Here is the code I have currently:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("AM8")) Is Nothing Then
Select Case Range("AM8")
Case "FY22": FY22
Case "FY23": FY23
End Select
End If

If Not Intersect(Target, Range("AX8")) Is Nothing Then
Select Case Range("AX8")
Case "FY22": FY22
Case "FY23": FY23
End Select
End If

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi and welcome to MrExcel:

The 2 cells AM8 and AX8 must start with the original default value.

Put all of the following code in the events of your sheet:
VBA Code:
Option Explicit

Dim originaldefault As Variant

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Target.CountLarge > 1 Then Exit Sub
  If Not Intersect(Target, Range("AM8,AX8")) Is Nothing Then
    originaldefault = Target.Value
  End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.CountLarge > 1 Then Exit Sub
  If Not Intersect(Target, Range("AM8,AX8")) Is Nothing Then
    Select Case Target
      Case "FY22": FY22
      Case "FY23": FY23
    End Select
    Application.EnableEvents = False
    Target.Value = originaldefault
    Application.EnableEvents = True
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,659
Members
449,091
Latest member
peppernaut

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