Data Validation list from multiple columns.

mabubakerali

New Member
Joined
Feb 23, 2016
Messages
35
for example: Lets say i have data list in column a and data list in column B now i want apply data validation list in cell C1, Now i want C1 to drop down the list which includes the data from column a and column b in ascending order like it start from cell a1 and end on cell B5. Please help. I have also uploaded the file in case any one want to use that to help.
 

Attachments

  • Screenshot 2024-07-06 223404.png
    Screenshot 2024-07-06 223404.png
    2.7 KB · Views: 7

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If you want to do it using a formula, you may need to create a helper column combining col A & B. For example, you could put this formula
Excel Formula:
=VSTACK(A1:A5,B1:B5)
in Cell D1 and then reference the new list in col D (D1:D10) when defining your data validation rule.


Alternatively, you could opt for a VBA solution
VBA Code:
Sub RefreshValidation()
    Dim AA, AB
    
    With ActiveSheet
        AA = .Range("A1:B5").Value
        AB = Evaluate("ARRAYTOTEXT(TRANSPOSE(A1:B5))")
        
        With .Range("C1").Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=AB
        End With
    End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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