Array Help

Hi,

I have a data sheet. I also have a consultant sheet.

I would like to setup a 'lookup' array on the consultant sheet to dynamically return the ID values (orange) for the noted owner (yellow).

Thereby, if I change the owner on the consultant sheet, the data will update to the new owner. This data will grow over time.

Once I have this array syntax, I can create the arrays for the other.

Is this the best way of doing it? Or should I instead use some sort of filter setup that references the data sheet? The data sheet needs to stay raw, without a filter.


Thanks for your help

ee-array-owner.xlsx
LVL 1
dabug80Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
you can put this into worksheet "Consultant" 's sheet macro.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 1 And Target.Column = 2 Then
        Call updateWS
    End If
End Sub

Sub updateWS()
    Dim lastRow As Long
    Dim Owner As String
    
    Application.ScreenUpdating = False
    
    Owner = Sheets("Consultant").Cells(1, 2)
    
    Sheets("Consultant").Select
    lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
    ActiveSheet.Range("A4:R" & lastRow).Select
    Selection.Clear
    
    Sheets("Data").Select
    lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
    ActiveSheet.Rows("1:1").Select
    ActiveSheet.Range("B1").Activate
    Selection.AutoFilter
    ActiveSheet.Range("$A$2:$R$" & lastRow).AutoFilter Field:=3, Criteria1:=Owner
    ActiveSheet.Range("A2:R" & lastRow).Select
    Selection.Copy
    
    Sheets("Consultant").Select
    ActiveSheet.Range("A4").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    
    Sheets("Data").Select
    ActiveSheet.Range("A2").Select
    Selection.AutoFilter
    
    Sheets("Consultant").Select
    
    Application.ScreenUpdating = True
End Sub

Open in new window

ee-array-owner-b.xlsm
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Try this Array Formula (which requires confirmation with Ctrl+Shift+Enter instead of Enter alone.)

On Consultant Sheet,
In A4

=IFERROR(INDEX(Data!A$2:A$100,SMALL(IF(Data!$D$2:$D$100=$B$1,ROW(Data!$B$2:$B$100)-ROW(Data!$B$2)+1),ROWS(A$4:A4))),"")

Open in new window

And then copy across and down until you get blank cells.
I have copied the formula up to row 25 and used a custom formatting to hide zeros returned by the formula in some of the columns. Adjust the formatting of the formula cells to match with the source sheet after copying the formula across and down the cells. I have already adjusted the formatting in the attached workbook.

For details see the attached.

**************************
Note:

Remember that an Array Formula is confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.  You will know the array is active when you see curly braces { } appear around your formula.  If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.  Press F2 on that cell and try again.
ee-array-owner.xlsx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dabug80Author Commented:
Cheers for your help. Worked very well.
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome. Glad it worked for you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

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.