![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 10:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com