on 10-05-2015 11:35 AM
Hi Everyone,
I need your help to write a VBA macro for a button, to refresh a single knwon worksheet in workbook.
It's not the active sheet.
Thanks.
Med Amine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Only thing I would add would be to disable screen updating so the refresh is happening in the background, also note if a sheet is hidden it can't be refreshed.
Leverage Application.ScreenUpdating = True/False to hide selecting the sheet to refresh it.
Leverage Sheet("SheetToRefresh).Hidden = True/False if the sheet is hidden from view
Thanks Ryan, I'm trying to refresh in Background, so i modified my code like this:
Sub RefreshSheet()
Dim epm As New FPMXLClient.EPMAddInAutomation
Application.ScreenUpdating = False
Sheets("SHEET1").Select
epm.RefreshActiveSheet
Sheets("HOME").Select
End Sub
But it doesn't work, any suggetion?
Thanks
Med Amine
Its important to turn functions back on if they are turned off while the vb is running. Here I've added all the items I normally use in my code mostly due to performance:
Sub RefreshSheet()
On Error Goto Abort
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlManual
Dim epm As New FPMXLClient.EPMAddInAutomation
Sheets("SHEET1").Select
epm.RefreshActiveSheet
Sheets("HOME").Select
Abort:
Application.DisplayAlerts = True
Application.Calculation = xlAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
User | Count |
---|---|
6 | |
5 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.