formula to consider a number as text or format when using vlookup or sumproduct

fayez_MrExcel

Active Member
Joined
Oct 29, 2005
Messages
437
Office Version
  1. 365
Platform
  1. Windows
i have a number code (no financial calculation) where the end user either put it as a number or text example 101800, while doing a vlookup, there are number code that is not recognize because of the format, what formula that i can use to consider both format. example : 1008000
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Look for both like this
=IFERROR(VLOOKUP(VALUE(Sheet1!A2),Sheet2!B:C,2,0),VLOOKUP(TEXT(Sheet1!A2,"@"),Sheet2!B:C,2,0))
 
Upvote 0
Look for both like this
=IFERROR(VLOOKUP(VALUE(Sheet1!A2),Sheet2!B:C,2,0),VLOOKUP(TEXT(Sheet1!A2,"@"),Sheet2!B:C,2,0))
It work in vlookup, how can i apply in sumproduct, see below formula i have have where the ProdCode 1 & 2 i have a doubt entered as as number instead of text

=SUMPRODUCT((ProdCode1=A3)*(ProdCode2=B3)*(Price)). Thanks
 
Upvote 0
Your sumproduct formula would be messy and possibly unreliable

Convert your data and make it consistent
One way:
Use a helper column with this formula to convert current values
EITHER to text with
=TEXT(X2,"@")
OR numbers with
=VALUE(X2)

EITHER use the helper column in VlookUp and SumProduct
OR copy and paste values in helper column over the original values in column X

AND ... prevent future data entry from being inconsistent ?
 
Upvote 0
It work in vlookup, how can i apply in sumproduct, see below formula i have have where the ProdCode 1 & 2 i have a doubt entered as as number instead of text

=SUMPRODUCT((ProdCode1=A3)*(ProdCode2=B3)*(Price)). Thanks
Is it a format problem or a formula problem? Your formula above will only give results when both product codes match.

As @Yongle has pointed out above, it is always preferable to fix the source data rather than to try and fix the result in the formula, this might work but no guarantees.

=SUMPRODUCT(((ProdCode1+0)=(A3+0))*((ProdCode2+0)=(B3+0))*(Price))

Taking shortcuts may save time now, but will lose more time later.
 
Upvote 0
I agree very much with both Jasonb75 and Yongle's statements above.

I provided 2 simple examples on how the SumProduct could work.

T202007a.xlsm
ABCDEF
1ResultCriteria #Amount
210180020020010010.00
31018002002001000100.00
4101800200.00
5
6
7ResultCriteria TextAmount
810180020020010010.00
91018002002001000100.00
10101800200.00
11
12
1dd
Cell Formulas
RangeFormula
B9,B2:B3B2=IFERROR(VLOOKUP(VALUE(A2),$E$2:$F$10,2,0),VLOOKUP(TEXT(A2,"@"),$E$2:$F$10,2,0))
C2:C3C2=SUMPRODUCT(--($E$2:$E$4=A2+0),($F$2:$F$4))
B8B8=IFERROR(VLOOKUP(VALUE(A8),$E$8:$F$10,2,0),VLOOKUP(TEXT(A8,"@"),$E$8:$F$10,2,0))
C8:C9C8=SUMPRODUCT(--($E$8:$E$10=A8&""),($F$8:$F$10))


=SUMPRODUCT(--($E$2:$E$4=A3),($F$2:$F$4)) works OK with number as expected
=SUMPRODUCT(--($E$2:$E$4=A2+0),($F$2:$F$4)) works OK with A2 Text and A3 as number

=SUMPRODUCT(--($E$8:$E$10=A8),($F$8:$F$10)) works with A2 as Text and Text Criteria as expected
=SUMPRODUCT(--($E$8:$E$10=A8&""),($F$8:$F$10)) works OK if A is Text or Number and Criteria is Text
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,344
Members
448,956
Latest member
Adamsxl

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