Connections vs RefreshAll

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,364
I'm fishing for some guidance. I've recently started a position in a new company that uses Excel for reporting extensively. Most rely upon MSSQL to extract data via ODBC connections from SQL Server and Oracle into Pivots.
The current level of automation tends to use (various) scripting options to execute a function call that initiates a few tasks including updating the data.

My question is this...I believe in some cases, particularly when it's one connection for all and you update each individual pivot, you're just doing the same task multiple times and RefreshAll is a better option. What about the ODBC Connections?

Through my best friend Google, I caught hints that sometimes what should happen doesn't always happen and it's sometimes prudent to do certain steps twice to ensure your data updates.

For example, I'm seeing this code snippet:
Code:
    For Each cn1 In ThisWorkbook.Connections
       If cn1.Type = xlConnectionTypeODBC Then
            Set odbcCn = cn1.ODBCConnection
            odbcCn.BackgroundQuery = False
            
       ElseIf cn1.Type = xlConnectionTypeOLEDB Then
            Set oledbCn = cn1.OLEDBConnection
            oledbCn.BackgroundQuery = False
       
       End If
    Next

Done in addition to either a Refresh.All or walking through the worksheets and doing a refreshtable on each pivot.

What's your thoughts?

Edit: I just had a doh moment when I realized what this snip probably is for - in case somebody accidentally turns on the background refresh.

Mike
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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