![]() |
VBA corruption
Hi,
I was working on some vba code - nothing complicated - adding a workbook, then adding sheets and so on. I could not tell why I kept getting errors adding a worksheet. for example, Workbook.Worksheet.Add would work but .add(After:= I) would result in an error. would , eventually abandoned the file and started afresh and found that the code works flawlessly. That file was created in Xl2007 and saved as an xl2003 file. It is running "in compatibility mode." Is this a common occurrence? Any fixes? HS |
VBA corruption
I'm surprised that code ever worked!
Your "I" should be a sheet (or worksheet/chart) object With ActiveWorkbook ..Worksheets.Add after:=.Sheets(.Sheets.Count) End With or Set oSht = ActiveWorkbook.Sheets.Count ActiveWorkbook.Worksheets.Add after:=oSht Both the above add a new worksheet after all sheets (incl chart sheets). You could of course change .Sheets.Count to a valid number, or Sheets to Worksheets Regards, Peter T "HSalim[MVP]" wrote in message ... Hi, I was working on some vba code - nothing complicated - adding a workbook, then adding sheets and so on. I could not tell why I kept getting errors adding a worksheet. for example, Workbook.Worksheet.Add would work but .add(After:= I) would result in an error. would , eventually abandoned the file and started afresh and found that the code works flawlessly. That file was created in Xl2007 and saved as an xl2003 file. It is running "in compatibility mode." Is this a common occurrence? Any fixes? HS |
All times are GMT +1. The time now is 02:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com