Array formula - searching 1st x characters of field value

craigexcel

Active Member
Joined
Jun 28, 2006
Messages
298
Office Version
  1. 2016
Platform
  1. Windows
I need to create a CSE formula that looks at, in part, only the 1st 5 characters of one of the fields. Specifically, one of the criteria is to find values in a field (column) that begin with "HOUSE". I'm not sure how to create the CSE formula to look at the 1st 5 characters to determine if a given record should be included in the sum or not. Is there a way to do this?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I need to create a CSE formula that looks at, in part, only the 1st 5 characters of one of the fields. Specifically, one of the criteria is to find values in a field (column) that begin with "HOUSE". I'm not sure how to create the CSE formula to look at the 1st 5 characters to determine if a given record should be included in the sum or not. Is there a way to do this?
Your problem description is incomplete in that the conditions are probably not fully spelled out...

Maybe one of...

=SUMIF(StringRange,X2&"*",SumRange)

where X2 houses a value like HOUSE.

Control+shift+enter, not just enter:

=SUM(IF(LEFT(CondRange1,5)=X2,IF(CondRange2=Y2,SumRange)))

where Y2 houses another condition to test for.

The latter can also be done with SUMIFS...

=SUMIFS(SumRange,CondRange1,X2&"*",CondRange2,Y2)
 
Upvote 0
I need to create a CSE formula that looks at, in part, only the 1st 5 characters of one of the fields. Specifically, one of the criteria is to find values in a field (column) that begin with "HOUSE". I'm not sure how to create the CSE formula to look at the 1st 5 characters to determine if a given record should be included in the sum or not. Is there a way to do this?
Something like this...

Book1
ABCD
2House Of Pain43_181
3Our House21__
4Horse Lipps66__
5House Party53__
6Little Pink Houses85__
7House Music85__
Sheet1

This formula entered in D2:

=SUMIF(A2:A7,"House*",B2:B7)
 
Upvote 0
Thanks Aladin & Biff, for your suggestions. Agreed, it looks like I needed to have included a bit more information. Following is the CSE formula I currently have: =SUM((INV!$C$5:$C$50000=O18)*(INV!$I$5:$I$50000=$N$2)*(INV!$X$5:$X$50000="YES")*(INV!$S$5:$S$50000))

--- where, [O18] = "HOUSE"
--- Col I is a numeric month value
--- Col X contains YES or NO
--- Col S contains the $$ values to be summed

So, I want to sum those values in Col S, where:
Col O values begin with "HOUSE",
Col I values = 7 (for July), and
Col X values = YES

Hopefully that's more clear. Thanks.
 
Upvote 0
Thanks Aladin & Biff, for your suggestions. Agreed, it looks like I needed to have included a bit more information. Following is the CSE formula I currently have: =SUM((INV!$C$5:$C$50000=O18)*(INV!$I$5:$I$50000=$N$2)*(INV!$X$5:$X$50000="YES")*(INV!$S$5:$S$50000))

--- where, [O18] = "HOUSE"
--- Col I is a numeric month value
--- Col X contains YES or NO
--- Col S contains the $$ values to be summed

So, I want to sum those values in Col S, where:
Col O values begin with "HOUSE",
Col I values = 7 (for July), and
Col X values = YES

Hopefully that's more clear. Thanks.
What version of Excel are you using?
 
Upvote 0
Thanks Aladin & Biff, for your suggestions. Agreed, it looks like I needed to have included a bit more information. Following is the CSE formula I currently have: =SUM((INV!$C$5:$C$50000=O18)*(INV!$I$5:$I$50000=$N$2)*(INV!$X$5:$X$50000="YES")*(INV!$S$5:$S$50000))

--- where, [O18] = "HOUSE"
--- Col I is a numeric month value
--- Col X contains YES or NO
--- Col S contains the $$ values to be summed

So, I want to sum those values in Col S, where:
Col O values begin with "HOUSE",
Col I values = 7 (for July), and
Col X values = YES

Hopefully that's more clear. Thanks.
Control+shift+enter, not just enter:
Code:
=SUM(
  IF(LEFT(INV!$C$5:$C$50000,LEN(O18))=O18,
  IF(INV!$I$5:$I$50000=$N$2,
  IF(INV!$X$5:$X$50000="YES",
    INV!$S$5:$S$50000))))

You might want also to work out a SUMIFS version (see my first post).
 
Upvote 0
Thanks to all for your suggestions! Aladin's CSE formula worked perfectly in Excel 2007.
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

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