Loop with Index, Match

JamesPa

New Member
Joined
Dec 23, 2020
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
Hello!
I have a workbook which has up to 280 worksheets in it. I need to pull the data from one cell into a consolidated worksheet (named WIP in the attached file). I have the formula for the index and match: =INDEX(Sheet1!$P$1:$P$387,MATCH($G$1,Sheet1!$H$1:$H$387,0),1). I need a VBA which will loop through each of the worksheets and return the number identified by the formula. Can someone help me out with a suggestion?
 

Attachments

  • 0822 1.png
    0822 1.png
    72.2 KB · Views: 5
  • 0822.png
    0822.png
    45.3 KB · Views: 6

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
1666742042989.png

1666742091963.png

Hopefully this helps with what I am wanting to do. The first pic is the WIP worksheet where I want to paste the data in the cell defined by the index match formula. The second is a pic of one of the worksheets with the data I need. Its the cell with 327 in it. I would like to code a loop to copy the data defined by the index match formula from each worksheet, then paste it into the WIP worksheet. Any assistance would be greatly appreciated.
 
Upvote 0
Total doses test bed 102622.xlsx
ABCDE
1
2
3DayDoses/day
41327
522
637
742
852
962
WIP
Cell Formulas
RangeFormula
B4B4=INDEX(Sheet1!$P$1:$P$387,MATCH($G$1,Sheet1!$H$1:$H$387,0),1)
B5B5=INDEX(Sheet2!$P$1:$P$387,MATCH($G$1,Sheet2!$H$1:$H$387,0),1)
B6B6=INDEX(Sheet3!$P$1:$P$387,MATCH($G$1,Sheet3!$H$1:$H$387,0),1)
B7B7=INDEX(Sheet4!$P$1:$P$387,MATCH($G$1,Sheet4!$H$1:$H$387,0),1)
B8B8=INDEX(Sheet5!$P$1:$P$387,MATCH($G$1,Sheet5!$H$1:$H$387,0),1)
B9B9=INDEX(Sheet6!$P$1:$P$387,MATCH($G$1,Sheet6!$H$1:$H$387,0),1)


Total doses test bed 102622.xlsx
ABCDEFGHIJKLMNOPQRST
9410:20:25 AM1Phase 3-1 (2 day dosing s6300234252 3078
959:20:29 AM1Phase 2-2 (3 day dosing 12000212240 2590
9610:20:22 AM1Phase 3-1 (2 day dosing s12000323360 2590
977:18:25 AM1Phase 4 - 13 Carries10000201100 2590
986:39:35 AM1Phase 2-1 (4 day dosing s16500201165 3078
99Totals by Drug/Dose Type:0033423032725497
100
101
102
Sheet1



Here are the mini sheets for my project. I have the formulas in the WIP worksheet which identifies the correct cell in the other worksheets (cell P990 in the mini sheet I uploaded). I am very new to coding so any assistance on a VBA which will loop through all worksheets, other than the WIP worksheet, copy the cell identified by the formula, then paste it in the WIP worksheet will be greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

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