Microsoft Query - Excel Subtotal Refresh

Takes2ToTango

Board Regular
Joined
May 23, 2023
Messages
55
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Figured out the solution for any future references. Due to the two parameters, both refresh on the cell was activated. Turning this off and putting a table refresh in solved the issue.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top