View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
goss[_9_] goss[_9_] is offline
external usenet poster
 
Posts: 1
Default vba to add and name worksheets

Hi ng
using xl xp pro

Recorded some code to add and rename worksheets to new wb

Sub Xtract()

Application.DisplayAlerts = False
Workbooks.Add
ChDir "C:\WINDOWS\Temp"
With ActiveWorkbook
..SaveAs Filename:="C:\WINDOWS\Temp\my_Labor_Data.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
_
ReadOnlyRecommended:=False, CreateBackup:=False

Sheets.Add
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "schedule_dat"

Sheets("Sheet2").Select
Sheets("Sheet2").Name = "actual_dat"

Sheets("Sheet3").Select
Sheets("Sheet3").Name = "budget_dat"
..Close
End With
Application.DisplayAlerts = True


End Sub
=================================

Execution stops after sheet 2.
wb now has 2 sheets with names as coded
sheet 3 is highlighted by debugger
unclear as to why


---
Message posted from http://www.ExcelForum.com/