Takes2ToTango
Board Regular
- Joined
- May 23, 2023
- Messages
- 69
- Office Version
- 365
- Platform
- Windows
Hi all. I have a Microsoft Query that I initially removed subtotals. I then use the user form to change the query date using two parameter cells. This then refreshes the query as it is supposed to. However, when I read the subtotals back in again, the query refreshes itself and screws up all of the data. This doesn't happen on the dates that are already in the parameter or already filtered, only when a new one is added in. Is there any way to prevent this refresh? (Unfortunately I cannot add a sample of data due to the contents)
VBA Code:
Sub RunData()
Application.EnableEvents = False
Worksheets("OT").Range("A4:G579").RemoveSubtotal
UserForm1.Show
Application.EnableEvents = True
End Sub
Sub removesubs()
Application.EnableEvents = False
Range("A3").Select
ThisWorkbook.Connections("Connection410").Refresh
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(5, 6), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Application.EnableEvents = True
End Sub