Hi All;
I'm setting up code so that users can pick what column(s) they want subtotaled in their reports (Excel 2000). The best way I found to do it was to use the Selection.Subtotal function in VB, and feed their selections into the TotalList:= argument with a variable.
What I have so far in the code takes the columns they specify, converts them to numeric, 1-base offset like the function Selection.Subtotal wants.
[tt]Selection.SubTotal GroupBy:=intGroupBy, Function:=xlSum, TotalList:=Array(varTotalList), replace:=False, PageBreaks:=False, SummaryBelowData:=True[/tt]
Where intGroupBy is an integer, and varTotalList is a Variant
My problem is that when varTotalList is a single number (24, for example), the code runs fine, but when varTotalList = "24,25", for example, I get "Run-time error 1004, Subtotal method of Range class failed". I've tried changing the variable type, changing how it goes in, format, everything, and I am stuck. This wouldn't be so horrid, excep this is one of those "Have it done tomorrow or don't bother coming in Wednesday" kind of things. Arg!
I've confirmed that the only problem is the varTotalList. intGroupby works fine, and the code is set up to build varTotalList with the proper ", " between numbers.
Does anyone know how to get the TotalList argument to accept a variable with more than one number, or have an alternate suggestion to make flexible subtotals?
I hope this all made sense.
I'm setting up code so that users can pick what column(s) they want subtotaled in their reports (Excel 2000). The best way I found to do it was to use the Selection.Subtotal function in VB, and feed their selections into the TotalList:= argument with a variable.
What I have so far in the code takes the columns they specify, converts them to numeric, 1-base offset like the function Selection.Subtotal wants.
[tt]Selection.SubTotal GroupBy:=intGroupBy, Function:=xlSum, TotalList:=Array(varTotalList), replace:=False, PageBreaks:=False, SummaryBelowData:=True[/tt]
Where intGroupBy is an integer, and varTotalList is a Variant
My problem is that when varTotalList is a single number (24, for example), the code runs fine, but when varTotalList = "24,25", for example, I get "Run-time error 1004, Subtotal method of Range class failed". I've tried changing the variable type, changing how it goes in, format, everything, and I am stuck. This wouldn't be so horrid, excep this is one of those "Have it done tomorrow or don't bother coming in Wednesday" kind of things. Arg!
I've confirmed that the only problem is the varTotalList. intGroupby works fine, and the code is set up to build varTotalList with the proper ", " between numbers.
Does anyone know how to get the TotalList argument to accept a variable with more than one number, or have an alternate suggestion to make flexible subtotals?
I hope this all made sense.