Using LEFT() within a SUMPRODUCT()

jbrouse

Active Member
Joined
Apr 28, 2005
Messages
329
Hello, everyone.

Can someone please assist me with using the LEFT() function with the following SUMPRODUCT() function?

=SUMPRODUCT('Sheet1'!$A$2:$A$100='Sheet2'!$L$5),--('Sheet1!$D$2:$D$100='Sheet2'!$F1),--('Sheet1'!$G$2:$G$100)

I want one of the conditions to check if the first 12 characters of each cell in a column match my lookup value (Sheet2, cell F1, for example).

Is this possible? How would the formula read?

Thanks in advance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try

=SUMPRODUCT('Sheet1'!$A$2:$A$100='Sheet2'!$L$5),--(LEFT('Sheet1!$D$2:$D$100,12)='Sheet2'!$F1),--('Sheet1'!$G$2:$G$100)
 
Upvote 0
try this
Code:
=SUMPRODUCT(--(Sheet1!$A$2:$A$100=Sheet2!$L$5),--(LEFT(Sheet1!$D$14:$D$100,12)=$F$1),Sheet1!$G$2:$G$100)
 
Upvote 0
What is the lookup value in Sheet2 F1 ?
And what type of data is in Sheet1 Column D ?
 
Upvote 0
The lookup value in sheet2 F1 is a alpha numeric part no. AW123456-789

Sheet1, column D has similar part nos, only a longer string - AW123456-78901A.

Thanks for your assistance!
 
Upvote 0
If this get's a correct result
=SUMPRODUCT('Sheet1'!$A$2:$A$100='Sheet2'!$L$5),--('Sheet1!$D$2:$D$100='Sheet2'!$F1),--('Sheet1'!$G$2:$G$100)
Given a complete part number in Sheet2 F1


Then I see no reason for this not to work
given first 12 digits of the same part number used in previous formula.
=SUMPRODUCT('Sheet1'!$A$2:$A$100='Sheet2'!$L$5),--(LEFT('Sheet1!$D$2:$D$100,12)='Sheet2'!$F1),--('Sheet1'!$G$2:$G$100)
 
Upvote 0
I'm an idiot. I was looking for 12 characters, but my part no. in Sheet2, F1 was 13 characters, so it was saying if these 12 characters are the same as these 13 characters, sum it up! I'm fairly confident that won't ever happen.

It works now.

Thanks to all of you for your help!
 
Upvote 0
Glad to help, thanks for the feedback..

Side note, this isn't really a problem, but is not necessary..

=SUMPRODUCT(--('Sheet1'!$A$2:$A$100='Sheet2'!$L$5),--(LEFT('Sheet1!$D$2:$D$100,12)='Sheet2'!$F1),--('Sheet1'!$G$2:$G$100))

Should just be
=SUMPRODUCT(--('Sheet1'!$A$2:$A$100='Sheet2'!$L$5), --(LEFT('Sheet1!$D$2:$D$100,12)='Sheet2'!$F1),'Sheet1'!$G$2:$G$100)


You only need to do the --(...) on parts that have an expression (is colA = to "xyz")
The range that is being summed does not need that syntax.
 
Upvote 0
My actual formula does not have that syntax. I was trying to figure out why it has it in my post. I think it is because my actual formula is a little different than what I posted (nested if), and I modified it to make it easier to understand.

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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