how to sum values of an unkown number of cells

C

Citizen

I have the months of a year in a row. In each column I have values (e.g.
$/Jan, $/Feb, $/March).
Now I want to write a formula that gives me the sum of the values for the
year to date (ie in March give me the sum of the values for Jan, Feb, & March
but no others).

I use "MONTH(NOW())" to get the current month.

How to I get the sum of the values for this variable number of cells (ie it
grows from 1 to 12 cell values depending upon the month of the year it is)?

thank you
 
D

Don Guillett

This will sum row 2 from col A to the column of the month of today=19 IF
March
=SUM(A2:INDEX(2:2,MONTH(TODAY())))
you could also use an offset formula
jan feb mar
1__10__8
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
(e-mail address removed)...
 
J

JLGWhiz

This assumes a headre row and that the months are listed consecutively
beginning in column A.

Sub motst()
LRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
x = Month(Now)
If x = 2 Then
myVal = Application.WorksheetFunction.Sum(Range("B2:B" & LRow))
MsgBox myVal
End If
End Sub
 
D

Dana DeLouis

How to I get the sum of the values for this variable number of cells (ie
it
grows from 1 to 12 cell values depending upon the month of the year it
is)?

One way. If we assume your data is in A1:L1

=SUM(OFFSET(A1,0,0,1,MONTH(NOW())))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top