First Letter in a string

gberg

Board Regular
Joined
Jul 16, 2014
Messages
205
Office Version
  1. 365
Platform
  1. Windows
I have this formula that I need to modify a bit. Currently it takes the first character in a string and compares it to a cell I've called "Product_Specific". The Product_Specific cell will contain one letter (i.e. A, B, C, D, ect.) The formula sums up all of the rows that start with the letter entered into the "Product_Specific" cell. The text in red below is the part of the formula that looks for the letter

=SUMPRODUCT(--(LEFT(Tbl_Backlog[Proj '#],1)=Product_Specific),--(Tbl_Backlog[Status]=Year_Current),--(Tbl_Backlog[Revenue]<POC_Amount),Tbl_Backlog[Revenue])

My issue is the cells all used to start with a letter (i.e. D0001, D0002, Dold, Dxxx, etc.) but now they could remain this way or they could start with something else (i.e. 71D0001, 71-D0001, etc.) If there is something in front of the first letter it will always be a number or a character such as a "-". What I want is to find the first letter in the string to compare it to the "Product_Specific" cell.

I have this formula that works to pull the first letter from a single cell
=MID(A18,MATCH(TRUE,ISERROR(VALUE(MID(A18,ROW(INDIRECT("1:"&LEN(A18))),1))),0),1)

I tried using this in the original formula above but replace the "A18" cell reference with "Tbl_Backlog[Proj '#]" but it does not work for me
=SUMPRODUCT(--(MID(Tbl_Backlog[Proj '#],MATCH(TRUE,ISERROR(VALUE(MID(Tbl_Backlog[Proj '#],ROW(INDIRECT("1:"&LEN(Tbl_Backlog[Proj '#]))),1))),0),1)=Product_Specific),--(Tbl_Backlog[Status]=Year_Current),--(Tbl_Backlog[Revenue]<POC_Amount),Tbl_Backlog[Revenue])

I hope this makes sense and would be grateful for any help

Thanks,

Greg
 
I think I will just go with the "helper" column,
In that case I am suggesting an alternative non-volatile formula for that, together with the corresponding updated SUM formula.
Remember too that the helper column can be hidden if you want.

gberg.xlsm
ABCD
1
2D65000
3
42021
53000000
6
7proj #statusRevenueFirstLetter
871D0001202110000D
971G0002202120000G
1071-PD5621202130000P
1171*DP2569202110000D
12328D354202140000D
13D3659820215000D
14
Sheet1
Cell Formulas
RangeFormula
C2C2=LET(rev,Tbl_Backlog[Revenue],SUM(FILTER(rev,(Tbl_Backlog[FirstLetter]=Product_Specific)*(Tbl_Backlog[status]=Year_current)*(rev<poc_amount),0)))
D8:D13D8=LET(p,[@[proj '#]],MID(p,MATCH(TRUE,ABS(CODE(MID(p,SEQUENCE(LEN(p)),1))-77.5)<13,0),1))
Named Ranges
NameRefers ToCells
poc_amount=Sheet1!$B$5C2
Product_Specific=Sheet1!$B$2C2
Year_current=Sheet1!$B$4C2
 
Upvote 0

Excel Facts

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

I can't say I understand your formulas but they do work very well. Thanks for your help and suggestions, I will put them to good use.

Thanks,

Greg
 
Upvote 0
You're welcome. :)

I forgot to state specifically that my 'FirstLetter' formula is assuming upper case letters only, as that is what your samples were like. If it is possible the first letter could be lower case, a small adjustment would be required.
 
Upvote 0
They should all be upper case, but just in case what would the adjustment be?
 
Upvote 0
They should all be upper case, but just in case what would the adjustment be?
The addition of the red here
=LET(p,[@[proj '#]],MID(p,MATCH(TRUE,ABS(CODE(MID(UPPER(p),SEQUENCE(LEN(p)),1))-77.5)<13,0),1))
 
Upvote 0
Solution

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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