 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Todd Frankson Guest
|
Posted: Fri Sep 08, 2006 11:30 pm Post subject: Subtotals in excel 2000 (XL9) |
|
|
This code in VBA :
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(4, 5),
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Is this:
var
xlApp:TOleVariant;
begin
try
SelfControl := False;
XlApp := GetActiveOleObject('Excel.Application'); // connect to
running instance
except
try
XlApp := CreateOleObject('Excel.Application'); // no running
instance, start new.
except
MessageDlg('Unable to start Excel', mtError, [mbOk], 0);
Exit;
end;
end;
//// here comes some code to open / select worksheet, ... etc
Xlapp.Selection.Subtotal(2, xlSum, VarArray(4, 5), True, False, True)
So it stands to reason that this code in VBA:
Selection.Subtotal GroupBy:=1, Function:=xlcount, TotalList:=Array(1),
Replace:=True, PageBreaks:=True, SummaryBelowData:=True
Would come to this:
ws.Range['B7','B7'].Subtotal(1, xlCOUNT, Vararray(1), True, True, True)
Unfortunately I get an error on Vararray(1). Missing operator or
semi-colon...
So I tried:
ws.Range['B7','B7'].Subtotal(1, xlCOUNT, Vararray(1,1), True, True, True)
Same error....
Any one can give me a suggestion??
Thanks |
|
| Back to top |
|
 |
Brian Hollister Guest
|
Posted: Sat Sep 09, 2006 1:59 am Post subject: Re: Subtotals in excel 2000 (XL9) |
|
|
Besides, possibly using a function call with an incorrect name. I am pretty
sure it should be VarArrayOf and not VarArray but i could be wrong. I think
your just missing something in the VarArrayOf call.
Try,
ws.Range['B7','B7'].Subtotal(1, xlCOUNT, VarArrayOf([1]), True, True, True)
or
ws.Range['B7','B7'].Subtotal(1, xlCOUNT, VarArrayOf([1,1]), True, True,
True)
hth,
brian
--
Got a big event coming up? Let us
help coordinate your event. For more
visit www.kissemgoodbye.com
"Todd Frankson" <tfrankson (AT) medtrials (DOT) com> wrote in message
news:4501b6c8 (AT) newsgroups (DOT) borland.com...
| Quote: |
This code in VBA :
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(4, 5),
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Is this:
var
xlApp:TOleVariant;
begin
try
SelfControl := False;
XlApp := GetActiveOleObject('Excel.Application'); // connect to
running instance
except
try
XlApp := CreateOleObject('Excel.Application'); // no running
instance, start new.
except
MessageDlg('Unable to start Excel', mtError, [mbOk], 0);
Exit;
end;
end;
//// here comes some code to open / select worksheet, ... etc
Xlapp.Selection.Subtotal(2, xlSum, VarArray(4, 5), True, False, True)
So it stands to reason that this code in VBA:
Selection.Subtotal GroupBy:=1, Function:=xlcount, TotalList:=Array(1),
Replace:=True, PageBreaks:=True, SummaryBelowData:=True
Would come to this:
ws.Range['B7','B7'].Subtotal(1, xlCOUNT, Vararray(1), True, True, True)
Unfortunately I get an error on Vararray(1). Missing operator or
semi-colon...
So I tried:
ws.Range['B7','B7'].Subtotal(1, xlCOUNT, Vararray(1,1), True, True, True)
Same error....
Any one can give me a suggestion??
Thanks
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|