Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Summing different # of rows

How do I write a macro that will enter the sum in the last row, regardless
of how many rows I have listed.

For example:
Will calculate ttl he but also he
Item Qty Item
Qty
A 1 F
7
B 2 G
8
C 3 H
9
Total: 6 I
10

J 11

Total: 45

Thank you very much for your help and expertise!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Summing different # of rows

Let me try rewriting that quest so it is more legible.
I would like to enter the sum of all previous rows when the number of rows
changes from worksheet to worksheet.
For example:
Worksheet1
Item Qty
A 1
B 2
C 3
Ttl: 6

In Worksheet2
Item Qty
A 1
B 2
C 3
D 4
E 5
Ttl: 15

Thank you for your help


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Summing different # of rows

Length = ActiveSheet.UsedRange.Rows.Count
sumtotal = WorksheetFunction.Sum(Range(Cells(1, 1), Cells(Length, 1)))
Cells(Length + 1, 1).Value = sumtotal


And in my macro there, change it so that wherever it says Cells(#,#)
the second number should be the number of the column that the data to
be summed is in.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Summing different # of rows

Length = ActiveSheet.UsedRange.Rows.Count
sumtotal = WorksheetFunction.Sum(Range(Cells(1, 1), Cells(Length, 1)))
Cells(Length + 1, 1).Value = sumtotal


And in my macro there, change it so that wherever it says Cells(#,#)
the second number should be the number of the column that the data to
be summed is in.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Summing different # of rows

Try this

=SUM(OFFSET(B2,,,COUNTA(A:A)-2))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"new2macros" wrote in message
...
Let me try rewriting that quest so it is more legible.
I would like to enter the sum of all previous rows when the number of rows
changes from worksheet to worksheet.
For example:
Worksheet1
Item Qty
A 1
B 2
C 3
Ttl: 6

In Worksheet2
Item Qty
A 1
B 2
C 3
D 4
E 5
Ttl: 15

Thank you for your help






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Summing different # of rows

something like

=AVERAGE(IF(B2:B102,B2:B10))

which is an array formula, so commit with Ctrl-Shift-Enter

--

HTH

RP
(remove nothere from the email address if mailing direct)


"new2macros" wrote in message
...
How do I write a macro that will enter the sum in the last row,

regardless
of how many rows I have listed.

For example:
Will calculate ttl he but also he
Item Qty Item
Qty
A 1 F
7
B 2

G
8
C 3

H
9
Total: 6 I
10

J 11

Total: 45

Thank you very much for your help and expertise!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Summing different # of rows

sorry, response to another question.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...
something like

=AVERAGE(IF(B2:B102,B2:B10))

which is an array formula, so commit with Ctrl-Shift-Enter

--

HTH

RP
(remove nothere from the email address if mailing direct)


"new2macros" wrote in message
...
How do I write a macro that will enter the sum in the last row,

regardless
of how many rows I have listed.

For example:
Will calculate ttl he but also he
Item Qty Item
Qty
A 1

F
7
B 2

G
8
C 3

H
9
Total: 6

I
10

J 11

Total: 45

Thank you very much for your help and expertise!





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 only certain rows rodchar Excel Discussion (Misc queries) 2 April 7th 09 09:10 PM
Summing up rows that only have all the values Rob Excel Discussion (Misc queries) 3 March 31st 09 09:46 AM
summing rows and columns RKS Excel Discussion (Misc queries) 2 April 14th 07 03:50 AM
Summing rows Jeff Garrett Excel Programming 2 December 1st 04 10:55 PM
Summing rows Kelly[_7_] Excel Programming 1 January 26th 04 05:14 PM


All times are GMT +1. The time now is 08:47 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"