[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

passing array in subtotal

Posted on 2011-03-16
4
Medium Priority
?
333 Views
Last Modified: 2012-05-11
I need to pass array in subtotal
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array( 1 to lastcolumn ), _
                Replace:=True, PageBreaks:=False, SummaryBelowData:=True

I am doing the above fn. Please help and let me know how to pass 1 to lastcoulmn in this array
0
Comment
Question by:Ruchi_Sas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:Ruchi_Sas
ID: 35147135
does any one has answer to this question? If yes, then please answer
0
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 35152833
You can do something like this. Probably not the most efficient, but it should do.

Dim arrSeries(), lgMin As Long, lgMax As Long

lgMin = 2
lgMax = 6

ReDim Preserve arrSeries(lgMax - lgMin)

For i = lgMin To lgMax
    arrSeries(i - lgMin) = i
Next

Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=arrSeries, Replace:=True, PageBreaks:=False, SummaryBelowData:=True

Open in new window


Thomas
0
 
LVL 39

Expert Comment

by:nutsch
ID: 35152839
something like this with the last column (you can't put the first column since you're grouping on it)

Sub Macro3()
'
' Macro3 Macro
Dim arrSeries(), lgMin As Long, lgMax As Long

lgMin = 2
lgMax = Cells(1, Columns.Count).End(xlToLeft).Column

ReDim Preserve arrSeries(lgMax - lgMin)

For i = lgMin To lgMax
    arrSeries(i - lgMin) = i
Next

Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=arrSeries, Replace:=True, PageBreaks:=False, SummaryBelowData:=True

End Sub

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question