Cell with data validation: Default to first item?

VBA_Newbie

Active Member
Joined
Jan 7, 2005
Messages
258
Hi folks,

I have a data validated cell which takes its valid entries from a dynamic named range. A macro I run changes the dynamic named range, and hence, the allowable entries of the data validated cell.

What I'm hoping to do is have the data validated cell 'default' to the first item in the dynamic named range everytime the macro is run. Any suggestions?

Many thanks in advance!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi,

try this
Code:
Sub set_to_first_validationitem()
'Erik Van Geit
'050514 0108
Dim VF As String

    With Range("A1")
    VF = .Validation.Formula1
    .Value = Range(Right(VF, Len(VF) - 1))(1)
    End With

End Sub




kind regards,
Erik
 
Upvote 0
you're WELCOME :-)
now it would be intresting to understand how it works ...
when I was a Newbie, and even now (knowing there are other ways to do this), I'm using this technique
Code:
Sub set_to_first_validationitem()
'Erik Van Geit
'050514 0108
Dim VF As String

    With Range("A1")
    VF = .Validation.Formula1
    MsgBox VF, 64, "VF"
    MsgBox Right(VF, Len(VF) - 1), 64, "Right(VF, Len(VF) - 1)"
    MsgBox Range(Right(VF, Len(VF) - 1))(1).Address(0, 0), 64, "Range(Right(VF, Len(VF) - 1))(1).Address(0, 0)"
    MsgBox Range(Right(VF, Len(VF) - 1))(1).Value, 64, "Range(Right(VF, Len(VF) - 1))(1).Value"
    .Value = Range(Right(VF, Len(VF) - 1))(1)
    End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,552
Members
453,052
Latest member
ezzat

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