Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do i copy a active sheet to a new sheet with code and everything


Hi

I have a workbook with 2 sheet's. Now i would like to make a copy off
the active sheet to a new file, that is not a problem but the thing is
that all the VBA code that i have on the master is not copied to the
new sheet/file. How do i do this with VBA code her below is the code
that i use today.

ActiveSheet.Copy
Fakturaname = keyvalue + "\Fakturor\" + Fakturanr
ActiveWorkbook.SaveCopyAs Filename:=Fakturaname
ActiveSheet.SaveAs Filename:=Fakturaname

Best regards
Karill


--
Karill
------------------------------------------------------------------------
Karill's Profile: http://www.excelforum.com/member.php...o&userid=33357
View this thread: http://www.excelforum.com/showthread...hreadid=531889

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How do i copy a active sheet to a new sheet with code and everythi

Dim s as String, bk as Workbook
Fakturaname = keyvalue + "\Fakturor\" + Fakturanr
ActiveWorkbook.SaveCopyAs Fakturaname
s = ActiveSheet.Name
set bk = Workbooks.Open(Fakturaname)
Application.DisplayAlerts = False
for each sh in bk
if sh.name < s then
sh.Delete
end if
Next
bk.Save

--
Regards,
Tom Ogilvy


"Karill" wrote:


Hi

I have a workbook with 2 sheet's. Now i would like to make a copy off
the active sheet to a new file, that is not a problem but the thing is
that all the VBA code that i have on the master is not copied to the
new sheet/file. How do i do this with VBA code her below is the code
that i use today.

ActiveSheet.Copy
Fakturaname = keyvalue + "\Fakturor\" + Fakturanr
ActiveWorkbook.SaveCopyAs Filename:=Fakturaname
ActiveSheet.SaveAs Filename:=Fakturaname

Best regards
Karill


--
Karill
------------------------------------------------------------------------
Karill's Profile: http://www.excelforum.com/member.php...o&userid=33357
View this thread: http://www.excelforum.com/showthread...hreadid=531889


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do i copy a active sheet to a new sheet with code and everything


Many thanks for the quick reply! I did make an test with the code but
do rescive an error when i run it.
Run-time error '438'
Object doesn't support this property or method

On this row

For Each Sh In bk


Best regards
Karil

--
Karil
-----------------------------------------------------------------------
Karill's Profile: http://www.excelforum.com/member.php...fo&userid=3335
View this thread: http://www.excelforum.com/showthread.php?threadid=53188

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy sheet and make new sheet active belvy123 Excel Discussion (Misc queries) 5 April 24th 08 03:33 PM
VB code to copy sheet format to another sheet ASU Excel Discussion (Misc queries) 12 August 10th 06 02:37 AM
Active Cell Copy And Paste Sheet to Sheet A.R.J Allan Jefferys New Users to Excel 4 May 4th 06 02:04 AM
Copy my active sheet to a new sheet and open with an input form Brad Withrow Excel Programming 0 April 6th 06 03:56 AM
Copy from active sheet and paste into new sheet using info from cell in active Ingve Excel Programming 3 January 23rd 06 09:57 PM


All times are GMT +1. The time now is 04:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"