NMiller007
Programmer
Hello,
Thanks to this forum, I've learned a lot about controlling Excel documents from within an Access macro. Most of the time, I can record the Excel macro and with a little tweaking (put a . in front of the line) get it to work in Access.
I am now converting an old Excel macro and I'm not sure how to use the Selection.Subtotal command (I've never even used in Excel).
Here is the original code:
When I put a period in front of those lines, Access give me a weird message box that just says 400 (I haven't added in any error checking yet). How can I get these to work in my macro? Here's more of my Access macro:
Thanks!
Thanks to this forum, I've learned a lot about controlling Excel documents from within an Access macro. Most of the time, I can record the Excel macro and with a little tweaking (put a . in front of the line) get it to work in Access.
I am now converting an old Excel macro and I'm not sure how to use the Selection.Subtotal command (I've never even used in Excel).
Here is the original code:
Code:
Range("A1").Select
Selection.Subtotal GroupBy:=1, Function:=xlCount, TotalList:=Array(5), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(6), Replace:=False, PageBreaks:=False, SummaryBelowData:=True
When I put a period in front of those lines, Access give me a weird message box that just says 400 (I haven't added in any error checking yet). How can I get these to work in my macro? Here's more of my Access macro:
Code:
Set objXL = CreateObject("Excel.Application")
With objXL
.Visible = True
Set objWB = .Workbooks.Open("CMBS.xls")
.Columns("F:F").NumberFormat = "$#,##0.00"
.Columns("A:O").EntireColumn.AutoFit
.Range("A1").Select
.Selection.Subtotal GroupBy:=1, Function:=xlCount, TotalList:=Array(5), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
.Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(6), Replace:=False, PageBreaks:=False, SummaryBelowData:=True
.Range("A1").Select
.DisplayAlerts = False
.Save
End With
Thanks!