Access Validation Value on button click

B Rossio

New Member
Joined
May 25, 2021
Messages
30
Office Version
  1. 2019
Platform
  1. MacOS
How would I be able to see what a validation lists current value is after pressing a programed button. The idea is to have a dropdown list where an item is selected, the user pushes the button and then an action is taken upon that certain value selected in the list. A simple example is having a dropdown list of "Orange, Apple, Mango, Pear, Peach" and a Cell that has the text "This person's favorite fruit is:" and then they select it from the dropdown list and press the button. Let's say they select Apple, the cell would now read "This person's favorite fruit is an Apple"
VBA Code:
Sub DropDownList()

Range("A28").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Formula1:="Orange, Apple, Mango, Pear, Peach"

End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You could put list validation on a cell with the custom number format "This person's favorite fruit is "@
 
Upvote 0
The end process is going to be much more complicated than the example I'm using. Basically, I need to see what the user selected from the drop down menu, so that I can use it in multiple cells.
 
Upvote 0
The end process is going to be much more complicated than the example I'm using. Basically, I need to see what the user selected from the drop down menu, so that I can use it in multiple cells.
Here is a visual representation of a dumbed down version of what I would be trying to do.
 

Attachments

  • possible.jpg
    possible.jpg
    81.5 KB · Views: 11
Upvote 0
If you put a validation list in a cell, an absolute reference to that cell can be used in many other formulas.
 
Upvote 0
So, say the list is in cell A2 and the user chooses Apple, If I write a command that prints Range("A2") it will print "Apple"?
 
Upvote 0
Ok, I see that I does return the value selected when called upon. Thank you. But how do I call upon an action after a button click? I have absolutely no idea how to do that. I want the user to make a dropdown selection, press a button in the excel sheet, and then something happens based on what that user picked from the drop down list. Say they pick Mango, a 2 gets added to a certain cell. Or if they pick Peach, a 5 gets added to a certain cell (after the button click).
 
Upvote 0
Some code like this (where you've put validation on A2 as in post#6)

VBA Code:
Select Case Range("A2").Value 
    Case "Apple"
        ' do something
    Case "Mango"
        ' do something else
    Case "Orange"
        ' anohter thing
    Case Else
        ' fourth thing done
End Select
 
Upvote 0
Solution

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