Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to sum values of an unkown number of cells

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default how to sum values of an unkown number of cells

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


"Citizen" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Summing an unkown number of columns lesley1000 Excel Worksheet Functions 5 December 10th 07 10:15 AM
Highlight cells with certain number values Betsy Excel Worksheet Functions 1 November 26th 07 02:36 PM
Number of cells that have same values Lingyan Hu Excel Discussion (Misc queries) 6 December 8th 05 05:37 PM
VBA Pivot Tables with unkown # of rows in the data set Tbone_Scott Excel Programming 1 February 27th 04 01:34 AM
Passing an unkown range to a function Newbie3333 Excel Programming 3 December 5th 03 02:14 AM


All times are GMT +1. The time now is 09:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"