Excel Formula to Count Cells Starting with Specific Text as 0.5
Question details
The user needs a formula to calculate a total where all non-empty cells are counted as 1, but any cell starting with the letter 'H' (such as H, HV, HP, or HA) is assigned a specific value of 0.5.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating customized totals, such as attendance tracking where 'H' stands for 'Half Day', requiring different text strings to be weighted differently in the final sum.
- Observed behavior
- The user wants a single consolidated formula to accurately sum these custom weighted values without having to write long, complex nested IF statements for every individual cell in the range.
Verify your dataset range to ensure there are no unintended blank spaces inside the cells, and identify the exact row or column range (e.g., A2:Z2) you wish to calculate before building the formula.
Use SUMPRODUCT and LEFT to Assign 0.5 to Cells Starting with 'H'
This is the most efficient and recommended approach. It combines SUMPRODUCT and LEFT functions to assign a value of 0.5 to any string starting with 'H', while counting all other non-empty cells as 1.
This formula works by first checking if a cell is not empty, which creates a base count of 1. It then checks if the very first character of the cell text is 'H'. If it is, the formula subtracts 0.5 from that specific cell's count.
Click on the empty cell where you want the final calculated total to be displayed.
Type the formula: =SUMPRODUCT((A2:Z2<>"")*(1-0.5*--(LEFT(A2:Z2,1)="H")))
Replace 'A2:Z2' in both places within the formula with the actual range of your data.
Press the Enter key to calculate the result. The formula will automatically parse the text, assign 0.5 to H-prefixes, and output your total.

Use SUMPRODUCT for Exact Matches Only
If your requirements change and you only want cells containing exactly the letter 'H' to be counted as 0.5 (ignoring strings like HV or HA), you can use a simpler subtraction method.
Calculate Custom Weights Easily with WPS Spreadsheet
WPS Spreadsheet fully supports SUMPRODUCT, LEFT, and all standard Excel formulas. It makes tracking customized attendance codes, grades, or project metrics simple, allowing you to execute advanced data calculations efficiently.
- 1. Open your file: Launch WPS Spreadsheet and open your existing workbook containing the data.
- 2. Select target cell: Click on the cell where the final weighted tally should appear.
- 3. Enter the formula: Type your SUMPRODUCT formula into the formula bar.
- 4. Apply calculation: Press Enter to instantly process the text values and display your custom weighted sum.

Frequently Asked Questions
Can I adapt this formula to target a different letter besides 'H'?
Yes, you can easily change the target letter. Simply replace the 'H' in the formula with any letter you need. For instance, using ="V" at the end of the LEFT function will apply the 0.5 deduction to cells starting with 'V'.
Is the LEFT function case-sensitive in this formula?
No, the LEFT function combined with the standard equals operator (=) is not case-sensitive. It will treat both uppercase 'H' and lowercase 'h' as a match and assign them the 0.5 value.
How do I change the formula to count 'H' values as 0.25 instead of 0.5?
To change the custom value weight, simply locate the '0.5' in the formula (1-0.5*...) and change it to the deduction amount you need. To make 'H' worth 0.25, you would deduct 0.75 from the full value of 1. Therefore, you would use (1-0.75*...).
What if my cells contain extra spaces before the letter 'H'?
If there is a leading space, the LEFT(A2:Z2,1) function will extract the space instead of the 'H', causing the formula to fail. You can wrap the cell range in the TRIM function like this: LEFT(TRIM(A2:Z2),1)="H" to ignore accidental spaces.




