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

#### SamCha

##### New Member
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.

### Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

#### Joe4

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.

#### Joe4

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

#### SamCha

##### New Member
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.

You are welcome.

Replies
0
Views
81
Replies
3
Views
64
Replies
1
Views
59
Replies
0
Views
70
Replies
17
Views
288

1,127,266
Messages
5,623,722
Members
415,985
Latest member
salman101

### 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.

### Which adblocker are you using?

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

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