Thread: Copy Worksheet
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Sri via OfficeKB.com Sri via OfficeKB.com is offline
external usenet poster
 
Posts: 20
Default Copy Worksheet

Hello Joel,

Thanks for your reply but unfortunately, your code is not working. Please
find my problem as follows.

Set currWb = ActiveWorkbook -- My present workbook "File A" is assigned to
currWb

currWb.Sheets("Overview").Copy -- A new workbook is created and Overview
sheet is copied into new workbook

Set destWB = ActiveWorkbook -- My present workbook "File A" is assigned to
destWb

currWb.Close savechanges:=False -- My present workbook "File A" is closed
where I have this macro. So, no code after this is executed. At the end, I am
left with a new workbook with name "Book 1" and "Overview" sheet in it,
unsaved.

Any help please... One more this thins that my source workbook contains more
than one sheet out of which I have to copy only selected worksheet.

Thanks
Sri


joel wrote:
destWBName = vPath & "\LCM_Report_" & inpDate & ".xls"
'currWB = vPath & "\" & vName
Application.DisplayAlerts = False

Set currWb = ActiveWorkbook

If Dir$(destWB, vbNormal) = "" Then

Application.DisplayAlerts = True

'copy without After will create new workbook automatically
currWb.Sheets("Overview").Copy
Set destWB = ActiveWorkbook
currWb.Close savechanges:=False

With destWB
.Sheets("Overview").Copy _
After:=.Sheets(.Sheets.Count)
End With
destWB.SaveAs Filename:=destWBName
End If

Thanks joel for your reply but I still have same problem. See my exact code
as follows.

[quoted text clipped - 35 lines]

Sri


--
Message posted via http://www.officekb.com