Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is possible. One way to approach this is to call a sub that lists you the relevant agents whenever the Target in your Worksheet_Change intersects with validation cell1 or cell2 -> the validation changed.</p> <p>Then you would run a sub with 3 paramenters srcRange, validationColumn and validationValue that goes throgh each row of srcRange and checks if the cell on position rownumber, validationColumn is equal to validationValue if so it outputs the agent and sets outputrow + 1</p> <p>Put this VBA in your Sheet:</p> <pre><code>Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim watchRange As Range Dim validationValue As Range Dim validationColumn As Integer Set watchRange = Me.Range("H1, I1") ' Validation Cells ' If Not Intersect(Target, watchRange) Is Nothing Then Set validationValue = Me.Range("I1") validationColumn = 0 With Me.Range("H1") If (.value = "X") Then validationColumn = 2 If (.value = "Y") Then validationColumn = 3 If (.value = "Z") Then validationColumn = 4 End With listAgents Me.Range("B3:E6"), validationColumn, validationValue End If End Sub Private Sub listAgents(ByRef srcRange As Range, ByVal validationColumn As Integer, ByRef validationValue As Range) Dim outputStart As Range Dim row As Range Dim i As Long Set outputStart = Me.Range("H3") outputStart.CurrentRegion.Clear If validationColumn = 0 Then MsgBox "Can't find Validation Column" Exit Sub End If i = 0 For Each row In srcRange.Rows If (row.Cells(1, validationColumn) = validationValue) Then outputStart(1 + i, 1) = row.Cells(1, 1) i = i + 1 End If Next row End Sub </code></pre> <p>I tested it on your example and it worked.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload