Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
About Corruption | Excel Discussion (Misc queries) | |||
Spreadsheet Corruption? | Excel Worksheet Functions | |||
Spreadsheet Corruption? | Excel Discussion (Misc queries) | |||
formula corruption | Excel Worksheet Functions | |||
Corruption? | Excel Programming |