Why won't this sheet delete?

  • Thread starter ragtopcaddy via OfficeKB.com
  • Start date
R

ragtopcaddy via OfficeKB.com

Why doesn't the following code, which runs without any errors, result in the
sheet named being deleted?

Set wkbkRpt = XLobj.Workbooks.Open(strRptPath)
wkbkRpt.Activate
Set shtTmplt = wkbkRpt.Sheets("MarketRpt")
shtTmplt.Delete
wkbkRpt.Worksheets(1).Activate
wkbkRpt.Save

Thanks,

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200807/1
 
G

Gary Brown

Check for spaces in the worksheet such as "MarketRpt ". Unnoticable but is
different from "MarketRpt".
--
Hope this helps.
If this post was helpfull, please remember to click on the ''''YES''''
button at the bottom of the screen.
Thanks,
Gary Brown
 
T

TomPl

Deleting a worksheet causes an alert message that could be foiling your
attempt. Consider:

Application.DisplayAlerts = False
ThisWorkbook.Worksheets("Sheet3").Delete
Application.DisplayAlerts = True
 
R

ragtopcaddy via OfficeKB.com

Thanks fellas!
Deleting a worksheet causes an alert message that could be foiling your
attempt. Consider:

Application.DisplayAlerts = False
ThisWorkbook.Worksheets("Sheet3").Delete
Application.DisplayAlerts = True
Why doesn't the following code, which runs without any errors, result in the
sheet named being deleted?
[quoted text clipped - 7 lines]

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200807/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top