A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Sub CopyWorksheet ActiveSheet.Copy After:=ActiveSheet End Sub
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a huge workbook where I need to copy numerous worksheets to the position immediately after the one being copied. I have another macro already to set the sheet names, so that is not a problem, but when I recorded the macro I want, it always copies the same worksheet regardless of the worksheet I start on, even with using relative references when recording, and places in the same place as before instead of based on the current worksheet. The code makes it clear why it is working the way it does. How do I get it to do it relative to the current worksheet?
Sub CopyWorksheet()
' CopyWorksheet Macro
Sheets("2046 SP No Development").Select
Sheets("2046 SP No Development").Copy Before:=Sheets(16)
End Sub
BTW, this workbook has been around for 25 years, so it is still based on the xls format. I am willing to update the format if necessary, but it will entail a lot of other work as it will break links into AutoCAD.
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Sub CopyWorksheet ActiveSheet.Copy After:=ActiveSheet End Sub
Thank you. I love it when I receive such an straight forward answer!