Blanks in dropdownlist

oskr989

New Member
Joined
Apr 7, 2011
Messages
8
Hi!

I would like to do a drop-down list that ignores blank cell in a range, here is an example
Excel Workbook
A
1Range1
2
3Test1
4
5
6Test2
7
8
9Test3
10
...

Here is the example of what the dropdown list should look like:
list.png


Hope you can help me, thanks.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try this code:
Code:
Private Sub Worksheet_Activate()
Dim r As Range, txt As String
For Each r In Range("A1", Range("A" & Rows.Count).End(xlUp))
    If Not IsEmpty(r) Then txt = txt & "," & r.Value
Next
With Range("C1")
    .Value = Empty
    With .Validation
        .Delete
        .Add Type:=xlValidateList, Formula1:=Mid$(txt, 2)
    End With
    .Select
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,290
Members
452,902
Latest member
Knuddeluff

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