want to count number of items in 2 seperate columns if both are more than zero

excel_help_wanted

New Member
Joined
Sep 16, 2011
Messages
3
Hello,

I am trying to figure out number and dollar sum of new items that were introduced. I have a huge data dump of 60,000 rows. Column A has current year dollar sales and column B has Dollas Sales Change vs Year Ago.

An item is new if Column A has dollar sales and Column B ($ sales chg vs Year Ago) also has the same dollar sales number.

Since it's a huge data dump, I only want to get a count of items that have the same dollar sales value in Column A and Column B and sum of dollar sales for the same.

Thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi and welcome to the board.
Here are a couple ideas for you.
One (a formula approach)
In another column somewhere (I used column E for this example) in E1 enter the formula:
Code:
=IF(A1=B1,A1,"")
and copy down column E as far as your data goes in columns A & B.Then, where ever you want your total, enter a simple sum formula:
Code:
=SUM(E1:E60000)
- Or, if in a column other than E: =SUM(E:E)


Or, for a vba approach:
Code:
Sub Demo()

Dim LstRw As Long, Rw As Range, Total As Long
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
Total = 0
For Each Rw In Range("A2:A" & LstRw)
  If Rw.Value = Rw(, 2).Value Then Total = Total + Rw.Value
Next Rw

MsgBox Total

End Sub
Either one of these help?
 
Last edited:
Upvote 0
Probably some version of array formulas. Try the following:

=COUNT(IF($A$2:$A$60000=$B$2:$B$60000,$B$2:$B$60000))

=SUM(IF($A$2:$A$60000=$B$2:$B$60000,$B$2:$B$60000,0))

You'll obviously need to update the data ranges to match your file, but it should work.

BTW, with array formulas, you need to hit CTRL+SHIFT+ENTER to get them to work correctly, hitting ENTER only causes errors.
 
Upvote 0
Probably some version of array formulas. Try the following:

=COUNT(IF($A$2:$A$60000=$B$2:$B$60000,$B$2:$B$60000))

=SUM(IF($A$2:$A$60000=$B$2:$B$60000,$B$2:$B$60000,0))

You'll obviously need to update the data ranges to match your file, but it should work.

BTW, with array formulas, you need to hit CTRL+SHIFT+ENTER to get them to work correctly, hitting ENTER only causes errors.
Thanks for the help. Both the formulas worked!
 
Upvote 0
Thanks for the help....they worked!!!



Hi and welcome to the board.
Here are a couple ideas for you.
One (a formula approach)
In another column somewhere (I used column E for this example) in E1 enter the formula:
Code:
=IF(A1=B1,A1,"")
and copy down column E as far as your data goes in columns A & B.Then, where ever you want your total, enter a simple sum formula:
Code:
=SUM(E1:E60000)
- Or, if in a column other than E: =SUM(E:E)


Or, for a vba approach:
Code:
Sub Demo()
 
Dim LstRw As Long, Rw As Range, Total As Long
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
Total = 0
For Each Rw In Range("A2:A" & LstRw)
  If Rw.Value = Rw(, 2).Value Then Total = Total + Rw.Value
Next Rw
 
MsgBox Total
 
End Sub
Either one of these help?
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

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