Microsoft Query - Excel Subtotal Refresh

Takes2ToTango

Board Regular
Joined
May 23, 2023
Messages
69
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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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