LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Handling Errors and MessageBox

Below is a sample of my code. During testing I determined that , there are
two way's the user can create an error; by not retrieving the data for the
data base and by running the Macro a second time. The macro is designed to
create a pivot table on the fly (once). What I need help with is revising
the code to only show the message box if there is an error and then exiting
the sub once they click the okay button on the message box. Now I get the
error message even if no error occurs while running the Sub. After I click
okay it finished the Sub Procedure.

Joel Mills

Sub CreatePivotTable()
Dim PTCache As PivotCache
Dim PT As PivotTable

Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Database")


On Error Resume Next

MsgBox "Did you Copy the Export and Run Cleanup?" _
& vbCrLf & "If not then run them before running this Macro"
_
& vbCrLf & " If you have then you must Delete" _
& vbCrLf & "the (Pivot) Worksheet before running this Macro"

Set PT = PTCache.CreatePivotTable(TableDestination:="",
TableName:="PercentTable")

With PT
.PivotFields("Week Ending").Orientation = xlColumnField
.PivotFields("Target Early % Comp.").Orientation = xlDataField
.PivotFields("Target Late % Comp.").Orientation = xlDataField
.PivotFields("Target Planned % Comp.").Orientation = xlDataField
.ColumnGrand = False
.RowGrand = False

End With

ActiveSheet.Name = "Pivot"
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing messagebox nc Excel Discussion (Misc queries) 1 March 22nd 05 02:49 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Handling errors in formulas (how annoying are they!) anon90210 Excel Discussion (Misc queries) 1 January 17th 05 01:26 PM
Working around a messagebox JustinR Excel Programming 1 May 26th 04 01:53 AM
Handling Errors from Worksheet Functions Nigel[_4_] Excel Programming 1 October 7th 03 07:46 PM


All times are GMT +1. The time now is 02:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"