adrienne0914

Board Regular
Joined
Mar 22, 2018
Messages
57
Office Version
  1. 2016
Platform
  1. Windows
Hi all,
I am trying to figure out the best formula for this problem. My workbook is more complicated, but in a nutshell here is what I'm trying to create a formula for:

Data Tab
ANIMALCOUNT
Cats18
Dogs245
Rabbits17

<tbody>
</tbody>


Animals tab
CatsY
DogsN
BearsY

<tbody>
</tbody>

Month tab
Jany
FebY
MarN

<tbody>
</tbody>

CM1CM2
Cats5075
Dogs4218
Bears2237

<tbody>
</tbody>

If animal=Y and month=Y, multiply COUNT by CM1, otherwise multiply COUNT by CM2. So for instance, both conditions are met by cat. So multiply 18*50.

I hope someone can help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,

I have used combination of IF and VLOOKUP to get to this, and for Month I have used today's date (=TODAY()) if you want you can change that with any particular month or refer to a cell where month is given. Just to see whether this works I had kept everything on the same tab. See if it fulfills your requirement:

ABCDEFGHIJKLMNOPQ
1ANIMALCOUNTAnswerCatsYJunyCM1CM2
2Cats18900DogsNFebYCats5075
3Dogs2454410RabbitsYMarNDogs4218
4Rabbits17374Rabbits2237

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
C2=IF(AND(VLOOKUP(A2,$F$1:$G$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),$K$1:$L$3,2,FALSE)="Y"),B2*VLOOKUP(A2,$O$2:$Q$4,2,FALSE),B2*VLOOKUP(A2,$O$2:$Q$4,3,FALSE))
C3=IF(AND(VLOOKUP(A3,$F$1:$G$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),$K$1:$L$3,2,FALSE)="Y"),B3*VLOOKUP(A3,$O$2:$Q$4,2,FALSE),B3*VLOOKUP(A3,$O$2:$Q$4,3,FALSE))
C4=IF(AND(VLOOKUP(A4,$F$1:$G$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),$K$1:$L$3,2,FALSE)="Y"),B4*VLOOKUP(A4,$O$2:$Q$4,2,FALSE),B4*VLOOKUP(A4,$O$2:$Q$4,3,FALSE))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Thanks for the replay, Aryatect. I think this will work, but I'm having problems translating to multiple tabs with my file setup. I'll let you know if it works.

ABCDEFGHIJKLMNOPQ
1ANIMALCOUNTAnswerCatsYJunyCM1CM2
2Cats18900DogsNFebYCats5075
3Dogs2454410RabbitsYMarNDogs4218
4Rabbits17374Rabbits2237

<tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
C2=IF(AND(VLOOKUP(A2,$F$1:$G$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),$K$1:$L$3,2,FALSE)="Y"),B2*VLOOKUP(A2,$O$2:$Q$4,2,FALSE),B2*VLOOKUP(A2,$O$2:$Q$4,3,FALSE))
C3=IF(AND(VLOOKUP(A3,$F$1:$G$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),$K$1:$L$3,2,FALSE)="Y"),B3*VLOOKUP(A3,$O$2:$Q$4,2,FALSE),B3*VLOOKUP(A3,$O$2:$Q$4,3,FALSE))
C4=IF(AND(VLOOKUP(A4,$F$1:$G$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),$K$1:$L$3,2,FALSE)="Y"),B4*VLOOKUP(A4,$O$2:$Q$4,2,FALSE),B4*VLOOKUP(A4,$O$2:$Q$4,3,FALSE))

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
I have moved the data as per your tabs named Data, Animals, Months & CM tab (there was no name so just adding this) then the final formula will look like below:

ABC
1ANIMALCOUNTAnswer
2Cats18900
3Dogs2454410
4Rabbits17374

<tbody>
</tbody>
Data

Worksheet Formulas
CellFormula
C2=IF(AND(VLOOKUP(A2,Animals!$A$1:$B$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),Months!$A$1:$B$3,2,FALSE)="Y"),B2*VLOOKUP(A2,'CM Tab'!$A$2:$C$4,2,FALSE),B2*VLOOKUP(A2,'CM Tab'!$A$2:$C$4,3,FALSE))
C3=IF(AND(VLOOKUP(A3,Animals!$A$1:$B$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),Months!$A$1:$B$3,2,FALSE)="Y"),B3*VLOOKUP(A3,'CM Tab'!$A$2:$C$4,2,FALSE),B3*VLOOKUP(A3,'CM Tab'!$A$2:$C$4,3,FALSE))
C4=IF(AND(VLOOKUP(A4,Animals!$A$1:$B$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),Months!$A$1:$B$3,2,FALSE)="Y"),B4*VLOOKUP(A4,'CM Tab'!$A$2:$C$4,2,FALSE),B4*VLOOKUP(A4,'CM Tab'!$A$2:$C$4,3,FALSE))

<tbody>
</tbody>

<tbody>
</tbody>

Happy to Help !!
 
Last edited:
Upvote 0
Thanks! I was able to work out the first part of the formula. My issue is with the B2. In my workbook, it won't be looking at a single cell. It will have to search a column on another tab (say Data) for a match, then go to the 'CM Tab' other part of the multiplication. Would that be another VLOOKUP?

Worksheet Formulas
CellFormula
C2=IF(AND(VLOOKUP(A2,Animals!$A$1:$B$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),Months!$A$1:$B$3,2,FALSE)="Y"),B2*VLOOKUP(A2,'CM Tab'!$A$2:$C$4,2,FALSE),B2*VLOOKUP(A2,'CM Tab'!$A$2:$C$4,3,FALSE))
C3=IF(AND(VLOOKUP(A3,Animals!$A$1:$B$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),Months!$A$1:$B$3,2,FALSE)="Y"),B3*VLOOKUP(A3,'CM Tab'!$A$2:$C$4,2,FALSE),B3*VLOOKUP(A3,'CM Tab'!$A$2:$C$4,3,FALSE))
C4=IF(AND(VLOOKUP(A4,Animals!$A$1:$B$3,2,FALSE)="Y",VLOOKUP(TEXT(TODAY(),"mmm"),Months!$A$1:$B$3,2,FALSE)="Y"),B4*VLOOKUP(A4,'CM Tab'!$A$2:$C$4,2,FALSE),B4*VLOOKUP(A4,'CM Tab'!$A$2:$C$4,3,FALSE))

<tbody>
</tbody>

<tbody>
</tbody>

Happy to Help !!
 
Upvote 0
Yes, you are right, that here I had used B2 as there was a single value there in the same table, if it is coming from some other tab, then B2 will be replaced by another VLOOKUP to get that value which will be used for calculation.
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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