SUM and COunt

Vasanth88ece

New Member
Joined
Feb 26, 2025
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Is it possible to count and sum in the range of values. Example. If ah column has numbers then it should sum it and if it is string it should count.
 
If the column will have numbers only or text only then try the formula shown in columns A & B below. If the column could have a mixture then perhaps the column D formula might be what you want?

25 03 03.xlsm
ABCD
1NumbersTextMixture
25aa
3f4
4d5
56f
64s
71549 | 2
Numbers or Text
Cell Formulas
RangeFormula
A7:B7A7=IF(COUNT(A2:A6),SUM(A2:A6),COUNTA(A2:A6))
D7D7=SUM(D2:D6)&" | "&COUNTIF(D2:D6,"?*")
 
Upvote 0
If the column will have numbers only or text only then try the formula shown in columns A & B below. If the column could have a mixture then perhaps the column D formula might be what you want?

25 03 03.xlsm
ABCD
1NumbersTextMixture
25aa
3f4
4d5
56f
64s
71549 | 2
Numbers or Text
Cell Formulas
RangeFormula
A7:B7A7=IF(COUNT(A2:A6),SUM(A2:A6),COUNTA(A2:A6))
D7D7=SUM(D2:D6)&" | "&COUNTIF(D2:D6,"?*")
Thank you !. But actually my data is like below. If the row has text it should count and the row has numbers it should sum. The row values will be in either text or number and not mix of both.


26/Thu27/Fri28/Sat29/Sun30/Mon31/Tue01/Wed02/Thu03/Fri04/Sat05/Sun06/Mon07/Tue08/Wed09/Thu10/Fri11/Sat12/Sun13/Mon14/Tue15/Wed16/Thu17/Fri18/Sat19/Sun20/Mon21/Tue22/Wed23/Thu24/Fri25/Sat26/Sun27/Mon28/Tue29/Wed30/Thu31/Fri
NANANANANANAAPPPPAAAPP---------------------
NANANANANANAH---S------S------S----1022S1212121212
NANANANANANAHPPW/OPPPPPPW/OPPPPPAW/OPPPPPPW/OPPPP--
NANANANANANA81010----------------------------
12121261212H121211S111111111112612121212121212121212121212NANANANANANA
 
Upvote 0
Hmm - you did say column in post 1 ;)



Yet you do have rows with both numbers and text

View attachment 122900
Hmm - you did say column in post 1 ;)

My bad. Okay For the count I m going to count a specific string and that row will never have a number by any chance.

In SUM range(My specific string wont be available) anyways it is going to ignore the text and only sum the numeric values. Correct me if my thinking is wrong.
 
Upvote 0
For the count I m going to count a specific string and that row will never have a number by any chance.

In SUM range(My specific string wont be available) anyways it is going to ignore the text and only sum the numeric values. Correct me if my thinking is wrong.
Could we have another (small - we don't need so many columns to demonstrate the concept) set of sample data and the expected results and explain again in relation to that sample data, including telling us what the "specific string" is in that data?
 
Upvote 0
Could we have another (small - we don't need so many columns to demonstrate the concept) set of sample data and the expected results and explain again in relation to that sample data, including telling us what the "specific string" is in that data?
johnPAPPI need to count the P present in this row
steve11234511I need to sum the values in this row
max12457878I need to sum the values in this row


I wanna do the above with sum and countif together. wherever countif is required it should perform countif similarly sum function. The above pattern is constant.
 
Upvote 0
Try this then

25 03 04.xlsm
BCDEF
2PAPP3
31123451190
412457878213
Sheet4
Cell Formulas
RangeFormula
F2:F4F2=IF(COUNT(B2:E2),SUM(B2:E2),COUNTIF(B2:E2,"P"))
 
Upvote 0

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