Ignore Blank Cells in Drop Down List

Subbie

New Member
Joined
May 11, 2019
Messages
23
Hi Following some very useful help yesterday I was able to plough on with my project.
I am now on my final UserForm and have a combobox2 which is coded:

Private Sub ComboBox2_DropButt*******()
With ComboBox2
ComboBox2.List = Worksheets("BankRec").Range("A1:A175").Value
End With
End Sub
This works great however There are blank cells at the beginning of the list that will always be in the column dropdown list and I would like the blank cells to be ignored so that the dropdown list starts with the first populated cell. I have tried various methods found on the web and tried a few of my own but I got compile errors or range errors.
Could anyone suggest a way to get the drop box to go to the first filled cell and ignore blank?
As always grateful for any help.
Subbie
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,991
Office Version
365
Platform
Windows
Are the values in col A unique?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,991
Office Version
365
Platform
Windows
If you're happy with unique values only, try
Code:
Private Sub ComboBox2_DropB[COLOR=#000000]utt[/COLOR][COLOR=#000000]*******[/COLOR]()
   Dim Cl As Range
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Worksheets("BankRec").Range("A1:A175")
         If Not Cl = "" Then .Item(Cl.Value) = Empty
      Next Cl
      Me.ComboBox2.List = .Keys
   End With
End Sub
 
Last edited:

Subbie

New Member
Joined
May 11, 2019
Messages
23
Are the values in col A unique?
Hi
Thanks for the response.
The setup is that the References are in Column A: CD1, CD2 etc.
When the user uses the Ref i.e. CD1 it is written to column G, CD1 is then removed from Column A. The way the deletion occurs means the ref CD1 remains in Column B which is a control column. So that means the Reference appears in 2 columns.

Subbie
 

Subbie

New Member
Joined
May 11, 2019
Messages
23
Hi
Thanks for the response.
The setup is that the References are in Column A: CD1, CD2 etc.
When the user uses the Ref i.e. CD1 it is written to column G, CD1 is then removed from Column A. The way the deletion occurs means the ref CD1 remains in Column B which is a control column. So that means the Reference appears in 2 columns.

Subbie
Was getting an error and realised it was my changing another variable.
Now working exactly as I need it to.
Very grateful for your wise advice.
Subbie
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,991
Office Version
365
Platform
Windows
You're welcome & thanks for the feedack
 

Forum statistics

Threads
1,081,543
Messages
5,359,431
Members
400,526
Latest member
Brook1083

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top