How to use VBA to autopopulate index match formula in a range of cells

valerieann

New Member
Joined
Jul 31, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
How do I use VBA to insert this index 3 match formula into a range of a column every time we refresh the source data? I think I need to use the Evaluate function but I haven't found an example of it producing a formula instead of a value.

Formula: =IFERROR(INDEX(Source!$D$1:$D$81, MATCH(1, ($A3=(Source!$A$1:$A$81)) * ($B$1=(Source!$C$1:$C$81)) * ($B$2=(Source!$B$1:$B$81)), 0)),"")


Fruit Price Chart.PNG
Fruit Price Source Data.PNG
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Welcome to the MrExcel board!

I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.

I am also not sure that you have given us the exact formula? Shouldn't this red $ sign be removed?
=IFERROR(INDEX(Source!$D$1:$D$81, MATCH(1, ($A3=(Source!$A$1:$A$81)) * ($B$1=(Source!$C$1:$C$81)) * ($B$2=(Source!$B$1:$B$81)), 0)),"")

Does anything at all get changed on the 'Chart' sheet when ...
we refresh the source data
If so, please give details.

If the data is just being refreshed on the 'Source' sheet then perhaps you could just have these formula in A3:E3 of the Chart sheet and provided where I have 1000 you use a number that will be sure to cover any amount of data you are likely to get, you wouldn't need to update anything on the Chart sheet.

Firstly, here is my 'Source' sheet (only goes to row 29)

valerieann.xlsm
ABCD
1DateStoreFruitPrice
28/01/2023KrogerApples1
38/02/2023KrogerApples1
48/03/2023KrogerApples1
58/04/2023KrogerApples1.5
68/05/2023KrogerApples1.5
78/01/2023KrogerOranges1
88/02/2023KrogerOranges1
98/03/2023KrogerOranges1
108/04/2023KrogerOranges1.5
118/05/2023KrogerOranges1.5
128/01/2023KrogerBananas0.5
138/02/2023KrogerBananas0.5
148/03/2023KrogerBananas0.5
158/04/2023KrogerBananas0.3
168/05/2023KrogerBananas0.3
178/01/2023KrogerStrawberries5
188/02/2023KrogerStrawberries5
198/03/2023KrogerStrawberries5
208/04/2023KrogerStrawberries4
218/05/2023KrogerStrawberries4
228/01/2023WalmartApples1.5
238/02/2023WalmartApples1.5
248/03/2023WalmartApples1.5
258/04/2023WalmartApples1.5
268/05/2023WalmartApples1.5
278/01/2023WalmartOranges2
288/02/2023WalmartOranges2
298/03/2023WalmartOranges2
30
Source


Then 'Chart' with formulas.

valerieann.xlsm
ABCDEF
1Apples
2KrogerWalmartTargetAldi
38/01/202311.5  
48/02/202311.5
58/03/202311.5
68/04/20231.51.5
78/05/20231.51.5
Chart
Cell Formulas
RangeFormula
A3:A7A3=LET(d,Source!A2:A1000,SORT(UNIQUE(FILTER(d,d<>""))))
B3:E7B3=LET(r,Source!$A2:$D1000,BYROW($A3#,LAMBDA(rw,FILTER(INDEX(r,0,4),(INDEX(r,0,1)=rw)*(INDEX(r,0,3)=$B$1)*(INDEX(r,0,2)=B2),""))))
Dynamic array formulas.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,138
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top