Script to select from a Data Validation dropdown

lewisthelemon

New Member
Joined
Dec 5, 2018
Messages
4
Hello, I am trying to generate a macro to select a particular name from a dropdown list. i tried using the record macro function, but the result was just a range.select
Is this possible? Thanks in advance
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I recorded a dropdown list my MyDefinedname and it worked.

Code:
 With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=[COLOR=#0000ff]MyDefinedName[/COLOR]"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
 
Upvote 0
@Kamolga Thank you for the reply.
My question may not have been clear. What I was asking is how to select the name from an already created list. I found a round-about way to do it, below is the code. If you could suggest any improvements it would be nice:

Code:
Sub Macro1()


Worksheets("Sheet1").Activate
With Worksheets("Sheet1")
    If .Range("B1").Value = "Costs" Then
        .Range("A1").Value = "FTE"
    Else
        .Range("B1").Value = "Range"
    End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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