Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Chris G
 
Posts: n/a
Default Sum a Column of Variable length

Hi,

I wish to put a total AT THE BOTTOM of a list of numbers in a macro.
The list is variable length and I want to use the subtotal(109, function as
there will be filters applied to the data and I only wish it to add items
displayed.

I tried this but it crashed on the last line. Help Please!!
LastRowNumber = Range("D65536").End(xlUp).Row
Moveup = LastRowNumber - 2
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(109,R[-Moveup]C:R[-1]C)"


  #2   Report Post  
Chris G
 
Posts: n/a
Default Sum a Column of Variable length

When I say "in a macro" I really mean "using a macro".
The list of numbers is in the spreadsheet and the formula is to be put in
the spreadsheet. Sorry about any potential confusion.

"Chris G" wrote:

Hi,

I wish to put a total AT THE BOTTOM of a list of numbers in a macro.
The list is variable length and I want to use the subtotal(109, function as
there will be filters applied to the data and I only wish it to add items
displayed.

I tried this but it crashed on the last line. Help Please!!
LastRowNumber = Range("D65536").End(xlUp).Row
Moveup = LastRowNumber - 2
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(109,R[-Moveup]C:R[-1]C)"


  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default Sum a Column of Variable length

Try

LastRowNumber = Range("D" & Rows.Count).End(xlUp).Row
MoveUp = LastRowNumber - 2
Cells(LastRowNumber + 1, "D").FormulaR1C1 = "=SUBTOTAL(9,R[-" & MoveUp &
"]C:R[-1]C)"


--

HTH

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


"Chris G" wrote in message
...
Hi,

I wish to put a total AT THE BOTTOM of a list of numbers in a macro.
The list is variable length and I want to use the subtotal(109, function

as
there will be filters applied to the data and I only wish it to add items
displayed.

I tried this but it crashed on the last line. Help Please!!
LastRowNumber = Range("D65536").End(xlUp).Row
Moveup = LastRowNumber - 2
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(109,R[-Moveup]C:R[-1]C)"




  #4   Report Post  
Chris G
 
Posts: n/a
Default Sum a Column of Variable length

that's clever ! I like it

Thanks

"Bob Phillips" wrote:

Try

LastRowNumber = Range("D" & Rows.Count).End(xlUp).Row
MoveUp = LastRowNumber - 2
Cells(LastRowNumber + 1, "D").FormulaR1C1 = "=SUBTOTAL(9,R[-" & MoveUp &
"]C:R[-1]C)"


--

HTH

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


"Chris G" wrote in message
...
Hi,

I wish to put a total AT THE BOTTOM of a list of numbers in a macro.
The list is variable length and I want to use the subtotal(109, function

as
there will be filters applied to the data and I only wish it to add items
displayed.

I tried this but it crashed on the last line. Help Please!!
LastRowNumber = Range("D65536").End(xlUp).Row
Moveup = LastRowNumber - 2
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(109,R[-Moveup]C:R[-1]C)"





  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default Sum a Column of Variable length

I had to do it that way as in my test data the last cell was in a completely
different column <G

--

HTH

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


"Chris G" wrote in message
...
that's clever ! I like it

Thanks

"Bob Phillips" wrote:

Try

LastRowNumber = Range("D" & Rows.Count).End(xlUp).Row
MoveUp = LastRowNumber - 2
Cells(LastRowNumber + 1, "D").FormulaR1C1 = "=SUBTOTAL(9,R[-" &

MoveUp &
"]C:R[-1]C)"


--

HTH

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


"Chris G" wrote in message
...
Hi,

I wish to put a total AT THE BOTTOM of a list of numbers in a macro.
The list is variable length and I want to use the subtotal(109,

function
as
there will be filters applied to the data and I only wish it to add

items
displayed.

I tried this but it crashed on the last line. Help Please!!
LastRowNumber = Range("D65536").End(xlUp).Row
Moveup = LastRowNumber - 2
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(109,R[-Moveup]C:R[-1]C)"







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
creating a bar graph Johnfli Excel Discussion (Misc queries) 0 October 26th 05 08:16 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM
Combining workbooks with some variable field names Bob Dobalina Excel Discussion (Misc queries) 8 May 17th 05 09:48 PM
how to create a variable column in cell reference Sampson Excel Worksheet Functions 3 February 21st 05 10:13 PM
Putting text in a column based on variable text from another colum Jacky D. Excel Discussion (Misc queries) 1 December 16th 04 06:09 PM


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