VBA sum the counts on different sheets to return the value in another sheet

SamCha

New Member
Joined
Nov 23, 2020
Messages
30
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I am trying to sum the counts in Sheet 2 (Range B:B) and Sheet 3 (Range B:B) and return the sum of the counts in Sheet 1 in Cell C2. The rows with value keeps varying in both the Sheets, However, for both the sheets the text (for eg abc) starts from Row 2.

Please can you help with a vba code for the above.

Thanks in advance.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Is this what you are looking for?
Excel Formula:
=SUM(Sheet2!B:B)+SUM(Sheet3!B:B)

If not, it might be helpful if you post some examples of your data along with your expected results, so that we can see exactly what you are after.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Sorry, missed the VBA part. Here is a VBA solution that returns that value:
VBA Code:
Sub MySum()

    Dim rng1 As Range
    Dim rng2 As Range
    Dim tot As Double
    
    Set rng1 = Sheets("Sheet2").Columns("B:B")
    Set rng2 = Sheets("Sheet3").Columns("B:B")
    
    tot = Application.WorksheetFunction.Sum(rng1) + Application.WorksheetFunction.Sum(rng2)
    
    MsgBox tot
    
End Sub
 
Upvote 0
Solution
Sorry, missed the VBA part. Here is a VBA solution that returns that value:
VBA Code:
Sub MySum()

    Dim rng1 As Range
    Dim rng2 As Range
    Dim tot As Double
   
    Set rng1 = Sheets("Sheet2").Columns("B:B")
    Set rng2 = Sheets("Sheet3").Columns("B:B")
   
    tot = Application.WorksheetFunction.Sum(rng1) + Application.WorksheetFunction.Sum(rng2)
   
    MsgBox tot
   
End Sub
Thanks a lot Joe4. This worked for me.
 
Upvote 0

Forum statistics

Threads
1,214,565
Messages
6,120,254
Members
448,952
Latest member
kjurney

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