Match function questions

MableMa

New Member
Joined
May 7, 2019
Messages
3
Dear,

Please help

Worksheet 1

[TABLE="width: 500"]
<tbody>[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]123456[/TD]
[TD][/TD]
[TD]290[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]234567[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Worksheet 2

[TABLE="width: 500"]
<tbody>[TR]
[TD]1[/TD]
[TD]<strike></strike>A
[/TD]
[TD]B<strike></strike>
[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]123456[/TD]
[TD]SP[/TD]
[TD]290[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]234567[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I would like to set a formula in Worksheet 1 cell C2.

I require to match Worksheet 1 Column A to Worksheet 2 Column A and if Worksheet 2 Column B has "SP". Worksheet 1 cell C1 should return the value of Worksheet 2 C2.

Please kindly help. :)
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
you can try PowerQuery

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td]source[/td][td][/td][td][/td][td][/td][td]result[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Column1[/td][td=bgcolor:#5B9BD5]Column2[/td][td=bgcolor:#5B9BD5]Column3[/td][td][/td][td=bgcolor:#70AD47]Column1[/td][td=bgcolor:#70AD47]Column2[/td][td=bgcolor:#70AD47]Custom[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
123456​
[/td][td=bgcolor:#DDEBF7]SP[/td][td=bgcolor:#DDEBF7]
290​
[/td][td][/td][td=bgcolor:#E2EFDA]
123456​
[/td][td=bgcolor:#E2EFDA]SP[/td][td=bgcolor:#E2EFDA]
290​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
234567​
[/td][td][/td][td]
444​
[/td][td][/td][td]
234567​
[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
444555​
[/td][td=bgcolor:#DDEBF7][/td][td=bgcolor:#DDEBF7]
333​
[/td][td][/td][td=bgcolor:#E2EFDA]
444555​
[/td][td=bgcolor:#E2EFDA][/td][td=bgcolor:#E2EFDA][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
666777​
[/td][td]SP[/td][td]
111​
[/td][td][/td][td]
666777​
[/td][td]SP[/td][td]
111​
[/td][/tr]
[/table]


Code:
[SIZE=1]// Table6
let
    Source = Excel.CurrentWorkbook(){[Name="Table6"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}, {"Column3", Int64.Type}}),
    IF = Table.AddColumn(Type, "Custom", each if Text.Contains([Column2], "SP") then [Column3] else null),
    Replace = Table.ReplaceErrorValues(IF, {{"Custom", null}}),
    RC = Table.RemoveColumns(Replace,{"Column3"})
in
    RC[/SIZE]
 
Upvote 0
you can try PowerQuery

[TABLE="class: head"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]source[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]result[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column1[/COLOR][/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column2[/COLOR][/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column3[/COLOR][/TD]
[TD][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column1[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column2[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Custom[/COLOR][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #DDEBF7"]
123456​
[/TD]
[TD="bgcolor: #DDEBF7"]SP[/TD]
[TD="bgcolor: #DDEBF7"]
290​
[/TD]
[TD][/TD]
[TD="bgcolor: #E2EFDA"]
123456​
[/TD]
[TD="bgcolor: #E2EFDA"]SP[/TD]
[TD="bgcolor: #E2EFDA"]
290​
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]
234567​
[/TD]
[TD][/TD]
[TD]
444​
[/TD]
[TD][/TD]
[TD]
234567​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #DDEBF7"]
444555​
[/TD]
[TD="bgcolor: #DDEBF7"][/TD]
[TD="bgcolor: #DDEBF7"]
333​
[/TD]
[TD][/TD]
[TD="bgcolor: #E2EFDA"]
444555​
[/TD]
[TD="bgcolor: #E2EFDA"][/TD]
[TD="bgcolor: #E2EFDA"][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]
666777​
[/TD]
[TD]SP[/TD]
[TD]
111​
[/TD]
[TD][/TD]
[TD]
666777​
[/TD]
[TD]SP[/TD]
[TD]
111​
[/TD]
[/TR]
</tbody>[/TABLE]


Code:
[SIZE=1]// Table6
let
    Source = Excel.CurrentWorkbook(){[Name="Table6"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}, {"Column3", Int64.Type}}),
    IF = Table.AddColumn(Type, "Custom", each if Text.Contains([Column2], "SP") then [Column3] else null),
    Replace = Table.ReplaceErrorValues(IF, {{"Custom", null}}),
    RC = Table.RemoveColumns(Replace,{"Column3"})
in
    RC[/SIZE]

I have not used Power Query before. Could you please kindly give me some steps for the above code?

Many thanks.
 
Upvote 0
Look at this link
Code:
[URL="https://excel.solutions/2017/11/power-query-paste-code-video/"][B]Power Query[/B]-How to use Mcode[/URL]
 
Upvote 0
try


Book1
ABC
1123456SP290
2234567
Sheet2



Book1
ABC
1123456290
2234567
Sheet1
Cell Formulas
RangeFormula
C1=IF(INDEX(Sheet2!B:B,MATCH(A1,Sheet2!A:A,0))="SP",INDEX(Sheet2!C:C,MATCH(A1,Sheet2!A:A,0)),"")
 
Upvote 0
If the values in Sheet2!A:A are unique, and the values in Sheet2!C:C are numeric, you can simply use in Sheet1!C2

=SUMIFS(Sheet2!C:C,Sheet2!A:A,A2,Sheet2!B:B,"SP")

A "not found" condition will show as a 0. If you just want a space, there are several ways to do that.
 
Last edited:
Upvote 0
try

ABC
SP

<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"]123456[/TD]

[TD="align: right"]290[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]234567[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet2



ABC

<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"]123456[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] , align: right"]290[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]234567[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C1[/TH]
[TD="align: left"]=IF(INDEX(Sheet2!B:B,MATCH(A1,Sheet2!A:A,0))="SP",INDEX(Sheet2!C:C,MATCH(A1,Sheet2!A:A,0)),"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

However I cannot get the second and third row right. Could you please give me more advises.

[TABLE="class: px"wysiwyg_dashes""]
<tbody style="border-collapse: collapse; width: auto;">[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH][/TH]
[TH]A[/TH]
[TH]B[/TH]
[TH]C[/TH]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: right"]123456[/TD]
[TD]SP[/TD]
[TD="align: right"]290[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: right"]234567[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: right"]345678[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: right"]456789[/TD]
[TD="align: right"]SP[/TD]
[TD="align: right"]600[/TD]
[/TR]
</tbody>[/TABLE]
Sheet2



[TABLE="class: px"wysiwyg_dashes""]
<tbody style="border-collapse: collapse; width: auto;">[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH][/TH]
[TH]A[/TH]
[TH]B[/TH]
[TH]C[/TH]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: right"]123456[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] , align: right"]290[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: right"]234567[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: right"]
456789
<strike></strike>
[/TD]
[TD="align: right"]<strike></strike>
[/TD]
[TD="align: right"]?[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: right"]123456[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
Sheet1

Many thanks for your help.
 
Upvote 0
it should work


Book1
ABC
1123456290
2234567
3456789600
Sheet1
Cell Formulas
RangeFormula
C1=IF(INDEX(Sheet2!B:B,MATCH(A1,Sheet2!A:A,0))="SP",INDEX(Sheet2!C:C,MATCH(A1,Sheet2!A:A,0)),"")



Book1
ABC
1123456SP290
2234567
3345678
4456789SP600
Sheet2
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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