SUM by number format

litrelord

Well-known Member
Joined
Dec 1, 2002
Messages
519
Hello again,

I've got rows of data which have a mixture of numbers and percentages which I need to sum. The percentages are every other column and I don't want them to be inlcuded in the sum. What I did to get the addresses for the cells I wanted summed was to write a piece of code that gave me a string that I could paste e.g. A1,C1,E1,G1 ETC

This is fine and it worked OK but I want to know if there's a forumla I could use instead. I was trying for a while to use SUMIF with the CELL function to look at the number format and see whether it was a percentage or not but coulsn't get it to work.

Does anyone have any ideas on a formula for this as it would be a hell of a lot nicer than using VBA?

Thanks

Nick
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,

This would sum every second column. e.g. A1, C1 etc.

=SUMPRODUCT((MOD(COLUMN(A1:I1),2)*A1:I1))

Would that do?
 
Upvote 0
Hi fairwinds,

thanks for that. It won't solve my immediate problem since the percentages may not always be every other row but that is definitely an interesting formula. I'd never used the MOD function before and I have to say I'm quite impressed. Mostly because I've always liked using the COLUMN function in formulas and then using fill, what a godsend. Anyway, I digress. Thanks again, if you think of any other ideas (or anyone else for that matter) I'd be happy to hear them.

Nick
 
Upvote 0
litrelord said:
...It won't solve my immediate problem since the percentages may not always be every other row but that is definitely an interesting formula. ...

You stated in your original post:

"The percentages are every other column and I don't want them to be inlcuded in the sum."

Now, what is the case?
 
Upvote 0
yeah sorry, I'm contradicting myself here. This time around it's every other column but next time or the time after it may not be.

As I said, the formula from fairwinds is nice but i was hoping to be able to sum by number format. Well, not so much hoping but interested in finding a way to do it.
 
Upvote 0
Well, I think the best way is to put a special heading in the columns you want to sum / not sum and use a SUMIF.

I don't think you can sum by format with a formula.
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,044
Members
448,543
Latest member
MartinLarkin

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