ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   create a copy of a sheet and insert it into the same workbook. (https://www.excelbanter.com/excel-programming/334630-create-copy-sheet-insert-into-same-workbook.html)

funkymonkUK[_54_]

create a copy of a sheet and insert it into the same workbook.
 

This is a piece of code I Got.

For Each sh In ActiveWorkbook.Sheets
' below to check if there is a worksheet with the name locally stored
data and if there is one then delet

If sh.Name = "Locally Stored Data" Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End If
Next sh

' copys a templatte sheet and then rename it and copy data etc.

Sheets("Temp").Visible = True
Sheets("Temp").Select
ActiveSheet.Copy
ActiveSheet.Name = "Locally Stored Data"
Sheets("Temp").Visible = False
Sheets("Data").Visible = True
Range("A9").Select
Selection.CurrentRegion.Select
Selection.Copy
Sheets("Locally Stored Data").Select
Range("A2").Select


It gets to the highlighted part and then copys the Sheet temp into a
new workbook instead of keeping it in the same workbook. any ideas?


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=387481



All times are GMT +1. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com