VBA to automate lookup formula based on 2 changing criteria.

SteynBS

Board Regular
Joined
Jun 27, 2022
Messages
104
Office Version
  1. 365
Platform
  1. Windows
Hi Guys,

I am in the process of automating a sheet for convenience, yes, but to save time as the preparation is a pain.

Firstly I have data in my "Generic" sheet Column A that I want in my "ATTYP" sheet as a header. I am doing this with =TOROW(UNIQUE(GENERIC[SITE_REP]),0,FALSE)
1668155496557.png

So I get my headers, copy and paste the values and convert the range to a table. This I can manage with a VBA, but. Now I have to put in my INDEX MATCH formula. The 1st condition is G1 (Header) to match with "Generic" sheet Column A. The Second Condition is "ATTYP" Sheet C2 to match with the "GENERIC" Sheet Column C - the formula looks something like this =INDEX(GENERIC[SATNR],MATCH(1,(GENERIC[SITE_REP]=Table3[[#Headers],[S011]])*(GENERIC[SATNR]=ATTYP[@LEFT]),0))
My problem is the 1st condition, the header will never be the same value, and headers G:K will either be less or more. So I need this formula to adapt according to the number of columns there will be and the value that will be in row one for the corresponding column. This formula has to repeat in each column that will have a header.

Hope it makes sense, and any assistance will be highly appreciated.
1668155565297.png
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Forget VBA and Formulas. Pull the first table into Power Query, change it as needed and then load the transformed table. Once done you can simply hit Refresh All to update the transformed table with new data. Power Query is easy to use (MUCH easier than VBA) and well worth the time to learn. Great playlists on it can be found here and here.
 
Upvote 0
Hi
Forget VBA and Formulas. Pull the first table into Power Query, change it as needed and then load the transformed table. Once done you can simply hit Refresh All to update the transformed table with new data. Power Query is easy to use (MUCH easier than VBA) and well worth the time to learn. Great playlists on it can be found here and here.
Hi,

My first table in the screenshot is pulled in via Power Query. Much of the data in the workbook comes in through Power Query. The second table is purely a process of elimination to select specific sets of data via the formula I demonstrated.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,199
Members
449,072
Latest member
DW Draft

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