Vlookup wih multiple conditions and repetations

aayush_agarwal

New Member
Joined
Feb 24, 2019
Messages
10
Hi everyone,
I am new to excel codng and require your help in solving the problem i am facing.
My data set contains different project (10 in total) with each project containing multiple materials (M1,M2,M3,M4...) under it. In front of each material is its corresponding volume. Note that inside a project the name of material may be repeated multiple number of times. My dataset looks similar to the data in the snapshot attached in the pic.

Sheet 1 : Input
ProjectMaterialVolume
Project 1M1V1
Project 1M2V2
Project 1M2V3
Project 1M4V4
Project 1M1V5
Project 1M3V6
Project 1M4V7
Project 1M3V8
Project 2M1V9
Project 2M2V10
Project 2M2V11
Project 2M4V12
Project 2M1V13
Project 2M3V14
Project 2M4V15
Project 2M1V16

<tbody>
</tbody>

I was looking for a formula or VBA code which would calculate the total volume corresponding to each material (M1,M2,M3,M4...) for each project (Project 1, project 2, project 3....). The output required in sheet 2 should look similar to the table shown below :
Output in sheet 2 :
ProjectMaterialTotal Volume
Project 1M1V1+V5
Project 1M2V2+V3
Project 1M3V6+V8
Project 1M4V4+V7
Project 2M1V9+V13+V16
Project 2M2V10+V11
Project 2M3V14
Project 2M4V12+V15

<tbody>
</tbody>

I have understood that i will have to use Vlookup formula with 2 search criteria, however i dont know how to take all volumes of a material inside a project. Fore example, in project 1 material M1 is repeated 2 times with respective volume V1 and V5. I want the output to be V1+V5 whereas Vlookup gives only the first occurance that is V1.
It would be great if you can give a formula or VBA code for solving this problem.
Thanks a lot for your help.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Not VLOOKUP but looks like SUMIFS.
Sheet2 D2 =SUMIFS(Sheet1!$D:$D,Sheet1!$A:$A,Sheet2!$A2,Sheet1!$B:$B,Sheet2!$B2)
 
Last edited by a moderator:
Upvote 0
@Flashbond Thanks for the input. Is it possible to give multiple disjoint columns as input instead of only one column B:
Code:
[COLOR=#333333]Sheet2 D2 =SUMIFS(Sheet1!$D:$D,Sheet1!$A:$A,Sheet2!$A2,(Look across multiple columns),Sheet2!$B2)[/COLOR]
The criteria_range2 in my case is a set of 3 disjoint columns.
Is i possible to modify the code to incorporate ths ?
Thanks a lot.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

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