raineb,
Attached is an example workbook based on the criteria described.
It has two worksheets, "Sheet1" and "Lists"
In sheet "Sheet1":
Row 2 is a header row so actual data starts on row 3
Column H is where you can enter the various items shown in the formula (QB1, CB7, VC10, RE1, MI1, etc)
Column I is the result based on what you chose/entered in the corresponding row in column H. Column I is governed by the macro code provided below.
In sheet "Lists":
Row 1 is a header row so actual data starts on row 2
Column A is the list of items that "Sheet1" column H can accept
Column B contains the various results for the entries available for "Sheet1" column H
Column A is defined by a dynamic named range with name "listHeaderH" whose formula is:
=Lists!$A$2:INDEX(Lists!$A:$A,MAX(2,COUNTA(Lists!$A:$A)))
Column D contains the drop down list that will be provided when a user selects "MI1" as the entry in "Sheet1" column H
The first line in the drop down list is "Select Item" so that the user will know that it is a drop-down list
This is further emphasized with conditional formatting on "Sheet1"
The drop-down list is also defined by a dynamic named range with name "listItems" whose formula is:
=Lists!$D$2:INDEX(Lists!$D:$D,MAX(2,COUNTA(Lists!$D:$D)))
(To view the named ranges, go to the Formulas tab and click Name Manager).
Lastly, in the "Sheet1" code module this worksheet_change event code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngChg As Range
Dim ChgCell As Range
Dim rngFound As Range
Dim rngDest As Range
Set rngChg = Intersect(Target, Me.Range("H3:H" & Rows.Count))
Application.EnableEvents = False
If Not rngChg Is Nothing Then
For Each ChgCell In rngChg.Cells
Set rngDest = Me.Cells(ChgCell.Row, "I")
rngDest.Clear
If Len(ChgCell.Text) > 0 Then
Set rngFound = Sheets("Lists").Columns("A").Find(ChgCell.Text, , xlValues, xlWhole)
If Not rngFound Is Nothing Then
Select Case (rngFound.Offset(, 1).Text <> "<DropDown>")
Case True: rngDest.Value = rngFound.Offset(, 1).Value
Case Else
With rngDest.Validation
.Delete
.Add xlValidateList, , , "=listItems"
End With
rngDest.Value = Sheets("Lists").Range("listItems").Cells(1).Text
End Select
End If
End If
Next ChgCell
End If
Application.EnableEvents = True
End Sub
To view the code, press Alt+F11 to open the Visual Basic Editor (VBE) and then double click on Sheet1.
Bookmarks