Data validation list

mehbodo

New Member
Joined
Mar 9, 2011
Messages
9
Is there a way to make a data validation list select an entire column bar the first row?

ie

Ref number
0001
0002
0003
0004

DV List will read

0001
0002
0003
0004

and if i decide to update source by adding 0005 it will be added to the DV List.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
With you validation cell "F1" and the validation list in column "A" try this:-
Code:
Private [COLOR="Navy"]Sub[/COLOR] Worksheet_SelectionChange(ByVal Target [COLOR="Navy"]As[/COLOR] Range)
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]If[/COLOR] Target.Address(0, 0) = "F1" [COLOR="Navy"]Then[/COLOR]
    [COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
    [COLOR="Navy"]With[/COLOR] Target
    .Select
    .Validation.Modify xlValidateList, xlValidAlertStop, _
    xlBetween, "=" & Rng.Address & ""
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Right click your sheet Tab, Select from Menu "View Code". VB Window appears.
Paste code into VB Window.
Change code ranges to suit, See Code
Close VB Window.
Rich (BB code):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Rng As Range
' Change Address Below (Red Font) of validation CELL  to Suit
If Target.Address(0, 0) = "F1" Then   
 Change Range (Red Font) of validation LIST  to suit 
Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
    With Target
    .Select
    .Validation.Modify xlValidateList, xlValidAlertStop, _
    xlBetween, "=" & Rng.Address & ""
End With
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

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