Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 define sub or function = please help

Author  Topic 

letovlondyne
Starting Member

3 Posts

Posted - 2015-02-14 : 13:25:25
Hi
can anyone help me to fix bug ? I get the word TempleMode marked in Yellow. Any idea what I should do ?

it's to clear all recoreds from my Pivot tables linked to SQL Database.

thanks
I.



Sub ClearAllSheets()

On Error Resume Next

'Dim pt As PivotTable
Dim Sh As Worksheet
Dim refresh As Boolean
Dim tempMode As Boolean
Dim startTime As Date

' Store the current time, used for the calculation of the elapsed time.
startTime = Now

Application.ScreenUpdating = True

' enable template mode
tempMode = TemplateMode(True)

' boolean to indicate that the sheet should not be refreshed with
' actual data.
refresh = False

' loop through all the workbook sheets.
For Each Sh In ActiveWorkbook.Sheets
If Not RefreshSheet(Sh, refresh) Then
Exit For
End If
Next

' the template mode was enables, so
' disable the template mode.
If tempMode Then
' disable template mode
TemplateMode False
End If

' In case of an error, end the procedure.
On Error GoTo RefreshAllSheetsError

'Update the elapsed time, required to complete the task.
Sheets("Technical Support").Range("A3").value = "Last ""Refresh all Sheets"" took " & DateDiff("s", startTime, Now) & " sec."

RefreshAllSheetsError:
' Trap errors in silence mode.

End Sub

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-14 : 13:28:57
YOu might want to to post this question in an Excel forum
Go to Top of Page
   

- Advertisement -