Reputation: 1
I have multiple columns of numbers each 12 rows long. The rows represent sales during each month. I'd like to add up each corresponding month. There are 4 columns of months to be added. How do you do this in Excel VBA?
There is a picture of my code at this link:
Upvotes: 0
Views: 80
Reputation: 16311
If you just want the total, you can do this. No need to create separate Range
objects:
total = Application.Sum(Range("F21:F32,F35:F46,F49:F60,F63:F74"))
Edit:
If you need to add respective indexes of each range to one another, you can use the Offset()
function to make things easier. For example:
For i = 0 To 11
Debug.Print Application.Sum(Range("F21,F35,F49,F63").Offset(i))
Next
Upvotes: 2
Reputation: 808
Do you need to use vba? if there are always a set number of numbers to add up, just use an excel formula
=SUM(A1:A12)
Upvotes: 1