Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
EF EF is offline
external usenet poster
 
Posts: 2
Default Subtotal for each column problem

I need to add subtotals to data which varies in both the number of row and
the number of columns.

I can determine the last row and the last column using;
xlApp.Range("A1").Select
z = xlApp.ActiveSheet.UsedRange.Column - 1 +
xlApp.ActiveSheet.UsedRange.Columns.Count
y = xlApp.ActiveSheet.UsedRange.Row - 1 +
xlApp.ActiveSheet.UsedRange.Rows.Count

My question is how do insert into a loop counting the coumn numbers a
calculation that subtotals, the data above it.

I have tried everything I can think of in terms of substituting variables
but no luck

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Subtotal for each column problem

Dim col as Range, rng as Range
for each col in ActiveSheet.UserRange.Columns
set rng = cells(rows.count,col.column).End(xlup)(2)
rng.FormulaR1C1 = "=Sum(R1C:R[-1]C)"
Next

--
Regards,
Tom Ogilvy



"ef" wrote in message
...
I need to add subtotals to data which varies in both the number of row and
the number of columns.

I can determine the last row and the last column using;
xlApp.Range("A1").Select
z = xlApp.ActiveSheet.UsedRange.Column - 1 +
xlApp.ActiveSheet.UsedRange.Columns.Count
y = xlApp.ActiveSheet.UsedRange.Row - 1 +
xlApp.ActiveSheet.UsedRange.Rows.Count

My question is how do insert into a loop counting the coumn numbers a
calculation that subtotals, the data above it.

I have tried everything I can think of in terms of substituting variables
but no luck

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
D D is offline
external usenet poster
 
Posts: 121
Default Subtotal for each column problem

Tom HTanks for the solution. . . . I've been banging my head for . . .

Anyway, how do I force the " rng.FormulaR1C1 " to place itself on the last
row of the range for all columns. Not all columns are the same row length.

Jeff

"Tom Ogilvy" wrote:

Dim col as Range, rng as Range
for each col in ActiveSheet.UserRange.Columns
set rng = cells(rows.count,col.column).End(xlup)(2)
rng.FormulaR1C1 = "=Sum(R1C:R[-1]C)"
Next

--
Regards,
Tom Ogilvy



"ef" wrote in message
...
I need to add subtotals to data which varies in both the number of row and
the number of columns.

I can determine the last row and the last column using;
xlApp.Range("A1").Select
z = xlApp.ActiveSheet.UsedRange.Column - 1 +
xlApp.ActiveSheet.UsedRange.Columns.Count
y = xlApp.ActiveSheet.UsedRange.Row - 1 +
xlApp.ActiveSheet.UsedRange.Rows.Count

My question is how do insert into a loop counting the coumn numbers a
calculation that subtotals, the data above it.

I have tried everything I can think of in terms of substituting variables
but no luck

Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Subtotal for each column problem

Dim col as Range, rng as Range
Dim rng1 as Range, lrow as Long
set rng1 = Activesheet.UsedRange
lrow = rng1.Rows(rng1.rows.count).row + 1
for each col in ActiveSheet.UserRange.Columns
set rng = cells(lrow,col.column).
rng.FormulaR1C1 = "=Sum(R1C:R[-1]C)"
Next

--
Regards,
Tom Ogilvy


"d" wrote in message
...
Tom HTanks for the solution. . . . I've been banging my head for . . .

Anyway, how do I force the " rng.FormulaR1C1 " to place itself on the last
row of the range for all columns. Not all columns are the same row length.

Jeff

"Tom Ogilvy" wrote:

Dim col as Range, rng as Range
for each col in ActiveSheet.UserRange.Columns
set rng = cells(rows.count,col.column).End(xlup)(2)
rng.FormulaR1C1 = "=Sum(R1C:R[-1]C)"
Next

--
Regards,
Tom Ogilvy



"ef" wrote in message
...
I need to add subtotals to data which varies in both the number of row

and
the number of columns.

I can determine the last row and the last column using;
xlApp.Range("A1").Select
z = xlApp.ActiveSheet.UsedRange.Column - 1 +
xlApp.ActiveSheet.UsedRange.Columns.Count
y = xlApp.ActiveSheet.UsedRange.Row - 1 +
xlApp.ActiveSheet.UsedRange.Rows.Count

My question is how do insert into a loop counting the coumn numbers a
calculation that subtotals, the data above it.

I have tried everything I can think of in terms of substituting

variables
but no luck

Thanks






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
Problem with subtotal function Constance Excel Worksheet Functions 0 March 17th 10 05:57 PM
Subtotal Problem Salman Excel Worksheet Functions 3 March 29th 07 10:08 AM
Subtotal & #n/a problem [email protected] Excel Programming 3 December 16th 04 07:43 AM
subtotal problem pcscsr[_6_] Excel Programming 0 November 1st 04 09:49 PM
subtotal problem pcscsr[_5_] Excel Programming 1 October 31st 04 10:54 PM


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