on 2016 Aug 16 7:51 AM
Hi Experts,
In workbook ,I am having around 10 sheets. I am using Workbook Refresh macro, there is no Worksheet refresh.
While I am doing Workbook refresh, I want to call Three macro's in between After refresh and before refresh. These three macro should call for two sheets only not for other sheets.
I am trying put if condition in Before Refresh and After Refresh Macro.
I am these macro's into Before /after refresh :CheckDel,Hiddenrrows and UnHiddenrows
But its not working as expected. Pls suggest me on the same.
Dim tem1 As String
Dim tem2 As String
Public Function AFTER_REFRESH() As String
If tem1="Sheetname1" Then
ChecknDel
AFTER_REFRESH = True
Else
If tem2="Sheetname2" Then
Hiddenrows
AFTER_REFRESH = True
Else
AFTER_REFRESH = False
End If
End If
End Function
--------------------------------------------------------
Dim tem_un As String
Public Function BEFORE_REFRESH() As String
If tem_un="Sheetname2" Then
UnHiddenrows
BEFORE_REFRESH = True
Else
BEFORE_REFRESH = False
End If
End Function
Message was edited by: BrahmaReddy Kolli
Request clarification before answering.
Sorry, but the explanation is totally unclear!
BEFORE_REFRESH and AFTER_REFRESH are triggered on the REFRESH event only once independent of the number of reports/sheets refreshed.
The code in BEFORE_REFRESH or AFTER_REFRESH has to specifically change the required sheets! And I don't see this code.
Your VBA is strange, what do you mean:
Dim tem1 As String
Dim tem2 As String
Public Function AFTER_REFRESH() As String '- AS STRING??? As Boolean!
If tem1="Sheetname1" Then '- tem1 is a not assigned variable, will never be Sheetname1
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
P.S. Sample:
You have 3 sheets with:
Sheet1 - 2 reports
Sheet2 - 1 report
Sheet3 - 1 report
Your Sheet1 is currently active and the cell of the first report is selected.
You press Refresh Report - only first report will be refreshed.
You press Refresh Worksheet - 2 reports will be refreshed
You press Refresh Workbook - all 4 reports on 3 sheets will be refreshed
In all cases you will have single BEFORE_REFRESH and AFTER_REFRESH events
| User | Count |
|---|---|
| 34 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.