Code in excel VBA to refresh SAS tables instead of pivot tables

Luigiportucale

New Member
Joined
Apr 12, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi. I am trying to do a Code in excel VBA to refresh SAS tables instead of pivot tables.
I have some tables that contain data and are connected to Statistical Analysis System (SAS) and I need to refresh them.

I am using this code to refresh everything once but sometimes it doesn’t work:

Sub Refresh_All_SAS()

Dim sas As SASExcelAddIn
Dim pt As PivotTable
Dim ws As Worksheet
Dim slcr As SlicerCache
Dim dblEndTime As Double



' Refresh SAS content

Set sas = Application.COMAddIns.Item("SAS.ExcelAddIn").Object
sas.Refresh ThisWorkbook

' Add a pause otherwise the update of the pivots doesn't work

dblEndTime = Timer + 1
Do While Timer < dblEndTime
DoEvents
Loop



'Refresh all pivots

For Each PivotCache In ActiveWorkbook.PivotCaches
PivotCache.Refresh
Next

' Remove selections

For Each slcr In ActiveWorkbook.SlicerCaches
slcr.ClearManualFilter
Next slcr

End Sub


So, this is to refresh all at once but sometimes does not work. If someone could help me with an easier code like just refreshing one SAS table, I would much appreciate it.

Thank you.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
How about:

VBA Code:
Sub SAS_Test()
Application.ScreenUpdating = False
Dim sas As Object
Set sas = Application.COMAddIns.Item("SAS.ExcelAddIn").Object
sas.Refresh Sheets("SAS Actuals").Range("A1")
Application.ScreenUpdating = True
MsgBox "SAS Actuals successfully loaded"
End Sub
 
Upvote 1
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,116
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