VBA/formula: if there's a cell in column B = 1, column D = 1, select that row and copy value in column H

JennV

New Member
Joined
May 9, 2019
Messages
34
Hello there,

I'm hoping to get some help/insight on how I'm able to complete this task.

On Sheet 1:
BD H
111.1
211.2
222.2
233.2
124.3

<colgroup><col width="64" span="8" style="width:48pt"> </colgroup><tbody>
</tbody>

On Sheet 2, for example, I want the value in column H in the row where column B=1 and column D=1 (in this case, "1.1").
Another example, I want the value in column H in the row where column B=1 and column D=2 (in this case, "4.3").

Thank you in advance!
 
Try something like this

=IF(<formulahere>formulahere=0,"",formulahere<formulahere>)

M.</formulahere></formulahere>


Sheet1:
111.1
211.2
222.2
230
12

<colgroup><col width="64" style="width:48pt" span="7"> </colgroup><tbody>
</tbody>


Sheet2:
111.1
222.2
23
12

<colgroup><col width="64" style="width:48pt" span="3"> </colgroup><tbody>
</tbody>


Thank you for that formula (works great for [1,2] - blank on Sheet1)! In the event that there is data equal to zero ([2,3]), the formula would make it blank on Sheet2 but I don't want it to be blank; it should display zero if Sheet1 says zero. Any workaround for this? Again, thank you VERY much!
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try

Sheet2

A
B
C
D
1
1​
1​
1,1​
2
2​
2​
2,2​
3
2​
3​
0​
4
1​
2​
5

Formula in C1 copied down
=IF(ISNUMBER(INDEX(Sheet1!H$1:H$5,MATCH(1,INDEX((Sheet1!B$1:B$5=A1)*(Sheet1!D$1:D$5=B1),),0))),SUMIFS(Sheet1!H$1:H$5,Sheet1!B$1:B$5,A1,Sheet1!D$1:D$5,B1),"")

M.
 
Upvote 0
Try

Sheet2

A
B
C
D
1
1​
1​
1,1​
2
2​
2​
2,2​
3
2​
3​
0​
4
1​
2​
5

<tbody>
</tbody>


Formula in C1 copied down
=IF(ISNUMBER(INDEX(Sheet1!H$1:H$5,MATCH(1,INDEX((Sheet1!B$1:B$5=A1)*(Sheet1!D$1:D$5=B1),),0))),SUMIFS(Sheet1!H$1:H$5,Sheet1!B$1:B$5,A1,Sheet1!D$1:D$5,B1),"")

M.


Amazing! Thank you so, so much!

I was playing around with it last night as well and discovered an alternative option, in case someone else is in the same boat as me:

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]=IFERROR(IF(ISBLANK(INDEX(Sheet1!$1:$1048576,MATCH(1,(Sheet1!$B:$B=Sheet2!B14)*(Sheet1!$D:$D=Sheet2!C14),0),8)),"",INDEX(Sheet1!$1:$1048576,MATCH(1,(Sheet1!$B:$B=Sheet2!B14)*(Sheet1!$D:$D=Sheet2!C14),0),8)),"-")

*need to CTRL+SHIFT+ENTER

This displays blanks as blanks and zeros as zeros. In addition, if your criteria are not met, it will display "-". I added this because I have a use for it.

Thank you again, M.[/FONT]
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,963
Members
449,200
Latest member
indiansth

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