Array Help


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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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 ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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)
    lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
    ActiveSheet.Range("A4:R" & lastRow).Select
    lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
    ActiveSheet.Range("$A$2:$R$" & lastRow).AutoFilter Field:=3, Criteria1:=Owner
    ActiveSheet.Range("A2:R" & lastRow).Select
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub

Open in new window

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


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.


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.

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.
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome. Glad it worked for you.
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.