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: 9
Default error while running macro, but not if stepping through lines.

Hello,

If I run my macro code it errors at a specific spot each time, but if I
break before and step through the code and resume it works. The error comes
affter the delete "Sheet1".

Any advice? Here are the specifc lines if it helps:
h = Sheets.Count
Dim wbA As Workbook
Dim wbNew As Workbook
With Application
SheetsInWb = .SheetsInNewWorkbook
.SheetsInNewWorkbook = 1
.DisplayAlerts = False
.ScreenUpdating = False
End With
Set wbA = ThisWorkbook
Set wbNew = Workbooks.Add
With wbNew
.SaveAs Filename:="C:\Documents and Settings\ty756c\My
Documents\contract project\" & programname & ".xls"
End With
hh = h - 5
hhh = 1
For copysheet = 1 To hh
wbA.Sheets(5 + hhh).Copy wbNew.Sheets(hhh)
hhh = hhh + 1
Next copysheet
wbNew.Sheets("Sheet1").Delete
ActiveWorkbook.BreakLink Name:= _
"C:\Documents and Settings\ty756c\Desktop\nbfgraph macro.xls",
Type:= _
xlExcelLinks
ActiveWorkbook.Save
ActiveWorkbook.Close


 
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
Stepping through v. running code Office_Novice Excel Programming 1 September 9th 08 07:12 PM
Different results when running macro vs stepping into macro Ken Steinhoff Excel Programming 4 September 20th 07 05:49 PM
Stepping through gives different result than running Gregg Roberts Excel Programming 10 September 22nd 06 08:42 PM
Error Message When running code but not stepping through it. Jared Excel Programming 4 November 16th 04 07:09 PM
VBA Code works by stepping through, not by running JbL Excel Programming 7 November 4th 04 02:49 PM


All times are GMT +1. The time now is 08:20 AM.

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

About Us

"It's about Microsoft Excel"