In cell validation using non-contiguous source range

arthur_etchells

Board Regular
Joined
May 15, 2004
Messages
169
Basically, I need the validation box to have as its source array a non-contiguous range of cell values. I couldn't get the validation list to take the non-contiguous range when entered in the formula1:= area, so I figured a named range would do the trick. However, I get an error at the validition.add line. The example below is a simplified mockup of the final version of the code, as the final version will need to draw on a larger number of cells.

Code:
Private Sub FillPickConditionFields(sh As Worksheet)
    sh.Cells.Validation.Delete
    ActiveWorkbook.Names.Add Name:="srtRng", RefersTo:="=Blur sheet!$A$4,Blur sheet!$E$4:$I$4"
    With sh.Range("C1").Validation
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=srtRng"
        .InCellDropdown = True
    End With
End Sub

Am I missing something here? Is it possible to use non-contiguous ranges in a validation drop-down like this?

Thanks for any help,
Arthur
 
Thanks! I guess I missed Damon's solution. Worked perfectly, I hadn't realized you could use a list like that in the formula1:= area. Thanks again for the help.
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,215,352
Messages
6,124,453
Members
449,161
Latest member
NHOJ

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