Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding sum to varying columns lengths


First post here. I'm a bit of noob and have only recorded macros in
excel and cleaned them up once done. Here is what I trying to figure
out.

I have 40+ data sheets in a workbook with rows of data ranging from 30
to 900 rows. At the close of each accounting month these sheets are
updated and the rows of data could either increase or decrease. I would
like to add code to my workbook that would find the first blank cell in
a given column (revenue remaining) and sum all data up to row 2(just
below heading). This codes needs to be able to work with any amount
rows, meaning not cell specific code.

Is this something someone could help me with and did I provide enough
information?

Many Thanks, Sam


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Adding sum to varying columns lengths

Since the Excel naming conventions will not allow spaces in a range name, I
will assume that 'revenue remaining' is a column header. Then for
demonstration purposes the code below will use column A as the revenue
remaining column.

Sub revrmngtot()
Dim lastRow As Long, sumRng As Range, Tot As Double
lastRow = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
sumRng = Sheets(1).Range("A2:A" & lastRow)
Tot = Application.WorksheetFunction.Sum(sumRng)
MsgBox Tot
Sheets(1).Rows(lastRow+1) = Tot
End Sub

The code finds the last row in the column that contains data and uses that
to establishe the range to total. The range is assigned to a variable so it
can be used elsewhere in the code if needed. Then the SUM function is used
to total the values in the range. The message box gives the same answer
that the last cell in the column will contain. If you do not delete the
total in the column, it will be included in the last row calculation the next
time the macro runs.

"Sam Conder" wrote:


First post here. I'm a bit of noob and have only recorded macros in
excel and cleaned them up once done. Here is what I trying to figure
out.

I have 40+ data sheets in a workbook with rows of data ranging from 30
to 900 rows. At the close of each accounting month these sheets are
updated and the rows of data could either increase or decrease. I would
like to add code to my workbook that would find the first blank cell in
a given column (revenue remaining) and sum all data up to row 2(just
below heading). This codes needs to be able to work with any amount
rows, meaning not cell specific code.

Is this something someone could help me with and did I provide enough
information?

Many Thanks, Sam


*** Sent via Developersdex http://www.developersdex.com ***

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
Create List sourced from Multiple sheets of varying lengths desertSol New Users to Excel 1 October 21st 09 10:05 PM
Sorting rows of data of varying lengths NDBC Excel Discussion (Misc queries) 12 July 4th 09 12:44 PM
sorting ranges of various column lengths, lookup values in columns mrphinney Excel Worksheet Functions 0 May 14th 09 07:51 PM
Economical grouping of lengths out of much longer lengths Richard (a Builder not a Mathematician) Excel Worksheet Functions 1 January 19th 08 10:28 PM
Adding cells that have varying contents Pierre Excel Worksheet Functions 5 September 12th 07 02:57 AM


All times are GMT +1. The time now is 01:01 AM.

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

About Us

"It's about Microsoft Excel"