PC Review


Reply
Thread Tools Rate Thread

Adding sum to varying columns lengths

 
 
Sam Conder
Guest
Posts: n/a
 
      11th Mar 2008

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 With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      11th Mar 2008
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create List sourced from Multiple sheets of varying lengths desertSol Microsoft Excel New Users 1 21st Oct 2009 10:05 PM
Sorting rows of data of varying lengths NDBC Microsoft Excel Misc 12 4th Jul 2009 12:44 PM
sorting ranges of various column lengths, lookup values in columns mrphinney Microsoft Excel Worksheet Functions 0 14th May 2009 07:51 PM
Parse table with field of varying lengths SAP2 Microsoft Access 20 26th Nov 2008 04:16 AM
Input masks for a field with varying data lengths/values =?Utf-8?B?QU1Ib2RnZXR0cw==?= Microsoft Access Database Table Design 1 22nd Nov 2004 05:58 PM


Features
 

Advertising
 

Newsgroups
 


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