VBA Sumif cell is a number

kitkatjam

New Member
Joined
Nov 30, 2018
Messages
10
I am trying to sum a range, say column A, but only if the corresponding row in column B is a number. Column B contains either numbers or "". I can't figure out how to say it.

Sumifs(Range(A:A), Range(B:B), IsNumeric) was my first attempt but didn't work. Any help would be greatly appreciated, thank you!
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,472
Office Version
  1. 365
Platform
  1. Windows
Just use ">0" for your criteria.
By the way, since there is only one conditions, SUMIF will do. No reason to need SUMIFS, i.e.
Code:
=SUMIF(B:B,">0",A:A)
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,424
Office Version
  1. 365
Platform
  1. Windows
How about
=SUMIF(B2:B15,"<>*",A2:A15)
 

kitkatjam

New Member
Joined
Nov 30, 2018
Messages
10
The problem is the "" come back as >0. Even though it's not a number, it's returning >0 = True so it ends up summing everything
 

kitkatjam

New Member
Joined
Nov 30, 2018
Messages
10

ADVERTISEMENT

This worked, thank you!!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,424
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,472
Office Version
  1. 365
Platform
  1. Windows
The problem is the "" come back as >0. Even though it's not a number, it's returning >0 = True so it ends up summing everything
Hmmm...
It doesn't do that for me.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,424
Office Version
  1. 365
Platform
  1. Windows
Using >0 works for me as well, as long as none of the values in col B are negative.
In fact >0 still works for me if the formula returns " " rather than "" in col B
 

Watch MrExcel Video

Forum statistics

Threads
1,109,161
Messages
5,527,156
Members
409,750
Latest member
BorisYeltsin

This Week's Hot Topics

Top