Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I had 3 questions realted to workbook copy/create:
1.I am trying to create a new new workbook and simultaneously saving it. On using an already existing name. I get run-time error 1004... I also used Application.DisplayAlerts = False but still Application.DisplayAlerts shows true to me. OTherwise how can i trap this 1004 error for file already existing error. I cannot use directly 1004 ..because run- tiem 1004 comes for lot many reasons. WHat is the error number to trap it? 2.i am using the below code to copy multiple worksheets in a newly created workbook With Workbooks(fileSaveName).Worksheets .Parent.Activate On Error Resume Next MsgBox "Now copying the selected Worksheets, to the newly created workbook " & fileSaveName & "." For i = 1 To totSht - 1 MsgBox Err.Number If .Item(DataWorksheet1(i)) Is Nothing Then DataWorksheet1(i).Copy After:=.Item(3) Else MsgBox "Error! Cannot copy the selected sheets!" End If Next i .Item("Sheet1").Delete .Item("Sheet2").Delete .Item("Sheet3").Delete End With If you notice I am using condition "If .Item(DataWorksheet1 (i)) Is Nothing Then" to enter into the loop which doesnt make sense. If i try using "If err.number < 0 " this fails...because it gives 0 at one time and 13 or 91 other time. IF i simply write the copy statement then on any error i cannot convey the user the message: MsgBox "Error! Cannot copy the selected sheets!" what condition can i use??? 3. I am using : DataWorksheet1(i).Copy After:=.Item(1) to copy....i try using before or after it doenst make any different on the way my sheets are being copied. My sheets are being copied on left...whereas i want them to be copied on the right..how can i achieve this Thanks tremendously... |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
create copy of sheet tab (excel 2007) when opening workbook | Excel Worksheet Functions | |||
Create a macro to copy data from one workbook to another | Excel Discussion (Misc queries) | |||
Workbook with different queries on each worksheet | New Users to Excel | |||
Workbook with 20+ queries of Access is TOO BIG | Excel Discussion (Misc queries) | |||
Where can I learn how to create parameter queries in Excel? | Excel Discussion (Misc queries) |