Creating Multiple Dropdowns

Tmf215

New Member
Joined
Feb 24, 2012
Messages
1
Hi,

I've encountered a very frustrating situation after conquering what I thought had been the hard part of my project. I spent a good part of today looking around on Google and this forum in search of a solution without having any success, so I'm hoping someone can give me a hand!

What I'm working with is a single workbook with two worksheets, ("A" and "B"), the first of which will be manipulated later and the second containing all of my gathered data.

For simplicity, lets say worksheet "B" has ten columns of data five rows deep. Row 1 contains titles and rows 2-5 contains data.

Worksheet "A" has the titles from Worksheet "B" (Row 1, Columns A - J) transposed into column A (Rows 1-10)

What I'm trying to do is have excel create dropdowns on worksheet "A" in column B based on the associated data on worksheet "B". I tried the obvious approach first by creating a data validation dropdown on Worksheet "A" B1 and dragging it down, but it simply repeats the same dropdown without changing the data source. If my real project was only 10 rows it wouldn't be a problem to manually create each dropdown, but my project requires over 600, so it's not really feasible to do each by hand.

This has been driving me crazy, so any help is greatly appreciated!
 

nightcrawler23

Well-known Member
Joined
Sep 24, 2009
Messages
721
U will have to modufy according to your data.

Code:
Sub Macro1()
Dim shA, shB As Worksheet
Set shA = Sheets("Sheet1")
Set shB = Sheets("Sheet2")

Dim valRange As Range
For i = 1 To 10
    Set valRange = shB.Range(shB.Cells(2, i), shB.Cells(Rows.Count, i).End(xlUp))
    With shA.Range("B" & i).Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=" & shB.Name & "!" & valRange.Address
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
Next i
End Sub
 

Forum statistics

Threads
1,082,168
Messages
5,363,537
Members
400,747
Latest member
monty_gl

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top