Match function questions

MableMa

New Member
Joined
May 7, 2019
Messages
3
Dear,

Please help

Worksheet 1

1ABC
2123456290
3234567

<tbody>
</tbody>


Worksheet 2

1<strike></strike>A
B<strike></strike>
C
2123456SP290
3234567

<tbody>
</tbody>

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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
you can try PowerQuery

sourceresult
Column1Column2Column3Column1Column2Custom
123456​
SP
290​
123456​
SP
290​
234567​
444​
234567​
444555​
333​
444555​
666777​
SP
111​
666777​
SP
111​

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

sourceresult
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column1[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column2[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column3[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column1[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column2[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Custom[/COLOR]
123456​
SP
290​
123456​
SP
290​
234567​
444​
234567​
444555​
333​
444555​
666777​
SP
111​
666777​
SP
111​

<tbody>
</tbody>


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
1123456SP290
2234567

<tbody>
</tbody>
Sheet2



ABC
1123456290
2234567

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C1=IF(INDEX(Sheet2!B:B,MATCH(A1,Sheet2!A:A,0))="SP",INDEX(Sheet2!C:C,MATCH(A1,Sheet2!A:A,0)),"")

<tbody>
</tbody>

<tbody>
</tbody>

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

ABC
1123456SP290
2234567
3345678
4456789SP600

<tbody style="border-collapse: collapse; width: auto;">
</tbody>
Sheet2



ABC
1123456290
2234567
3
456789
<strike></strike>
<strike></strike>
?
4123456

<tbody style="border-collapse: collapse; width: auto;">
</tbody>
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,218,124
Messages
6,140,622
Members
450,299
Latest member
ebculver

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