• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 532
  • Last Modified:

Excel Data Validation List Macro or Formula Help


Please see attached sample.  Im hoping someone can recommend either a formula or a macro that will do the following:

Once a position is selected from the data validation drop down list in sheet1, the person/s name and salary will populate starting in columns B15 and C15.  For example, if Waterboy is selected, both John Doe and Brad Pitt's name and salary would appear.  If quarterback is selected, the names would clear and only Tom Cruise's name and salary would appear.

Thank you for any assistance in advance!
  • 3
  • 2
1 Solution
Saqib Husain, SyedEngineerCommented:
Try this macro. Make sure that the spelling of Quarterback is the same in both sheets.

To install the macro
Right click on the sheet tab name of sheet1
select view code
paste the macro given below in the code pane

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cel As Range
    Application.EnableEvents = False
        If Target.Address = Range("B3").Address Then
            Range("B15:c" & Rows.Count).ClearContents
            With Sheets("Filled Position Data")
                For Each cel In .Range("E2:E" & .Range("E" & Rows.Count).End(xlUp).Row)
                    If cel.Value = Target.Cells(1, 1).Value Then
                        Range("B" & Rows.Count).End(xlUp).Offset(1, 1) = cel.Offset(, 12)
                        Range("B" & Rows.Count).End(xlUp).Offset(1, 0) = cel.Offset(, 6)
                    End If
                Next cel
            End With
        End If
    Application.EnableEvents = True
End Sub
EscanabaAuthor Commented:
One slight change.  If the names in the Filled Position data sheet are actually in column E how would I adjust this macro?
EscanabaAuthor Commented:
Sorry I mean in Column P.  Not E.
Saqib Husain, SyedEngineerCommented:
cel is where the position is

cel.Offset(, 6) means 6 cells to the right of cel

cel.Offset(, 12) means 12 cells to the right of cel

You can change the value of 6 or 12 by counting the columns to the right of the position cell
EscanabaAuthor Commented:
Thank you!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now