Copy Excel sheet without named ranges

There are a few different ways to copy named ranges in Excel. One way is to use the Name Manager. To do this, go to the Formulas tab and click on Name Manager. Then, select the named range you want to copy and click on the Copy button. You will then be able to paste the named range into another worksheet.

Another way to copy a named range is to use the Create From Selection feature. To do this, first select the cells that you want to name. Then, go to the Formulas tab and click on Create From Selection. In the Create Names dialog box, check only Left Column and click OK. This will create a named range for each row of data in your selection.

You can also use VBA to copy named ranges. To do this, open the Visual Basic Editor (VBE) by pressing Alt+F11. Then, insert a new module and paste the following code:

Sub CopyNamedRange()

  Dim ws1 As Worksheet
  Dim ws2 As Worksheet
  Dim nr1 As Name
  Dim nr2 As Name

  Set ws1 = ThisWorkbook.Sheets("Sheet1")
  Set ws2 = ThisWorkbook.Sheets("Sheet2")

  For Each nr1 In ws1.Names

     Set nr2 = ws2.Names.Add(Name:=nr1.Name, _
                            RefersToR1C1:=nr1.RefersToR1C1)

  Next nr1
End Sub

This code will loop through all of the named ranges in Sheet1 and create copies of them in Sheet2.

If you copy the sheet by going control c and then control v into the new workbook it does not bring across names and formats. If you right click copy sheet it does bring across all names and formats. So do the former.

If you absolutely must do the latter because you have lots of worksheets to copy, then you'll need to delete all names before you do so. You can do this for visible names through name manager as others have described. However this wont show hidden names which are often a problem. You'll need to find a VBA macro online to delete these.

You'd really have thought that in 2019 Microsoft would have put a "do you really want to do this" dialog warning when it sense the number of names you're about to copy, but that's Excel for you!

The tutorial provides a collection of macros to duplicate sheets in Excel: copy and rename based on cell value, copy multiple sheets, copy an active worksheet to another file without opening it, and more.

Manually copying sheets in Excel is pretty quick and straightforward... if performed just once or twice. Duplicating multiple sheets multiple times is boring and time consuming. On this page, you will find a handful of useful macros to automate this task.

Excel VBA to copy sheet to new workbook

This simplest one-line macro does exactly what its name suggests - copies the active sheet to a new workbook.

Public Sub CopySheetToNewWorkbook() activeSheet.Copy End Sub

Copy multiple sheets in Excel with VBA

If you'd like to copy several sheets from the active workbook to a new one, select all the worksheets of interest and run this macro:

Public Sub CopySelectedSheets() ActiveWindow.SelectedSheets.Copy End Sub

Excel VBA to copy sheet to another workbook

Depending on where you want to insert the copied sheet, use one of the following macros.

Copy sheet to the beginning of another workbook

This macro copies the active sheet before all other worksheets in the destination file, Book1 in this example. To copy to another file, replace "Book1.xlsx" with the full name of your target workbook.

Public Sub CopySheetToBeginningAnotherWorkbook() activeSheet.Copy Before:=Workbooks("Book1.xlsx").Sheets(1) End Sub

Copy sheet to the end of another workbook

This piece of code duplicates the active worksheet and places the copy to the end of Book1. Again, please remember to replace "Book1.xlsx" with the name of your destination workbook.

Public Sub CopySheetToEndAnotherWorkbook() activeSheet.Copy After:=Workbooks("Book1.xlsx").Sheets(Workbooks("Book1.xlsx").Worksheets.Count) End Sub

Note. For the macros to work, the target workbook must be saved on your hard drive or network.

Copy sheet to a selected workbook

To be able to copy the current sheet to any open workbook, you can create a UserForm (named UserForm1) with a ListBox control (named ListBox1) and two buttons:

Copy Excel sheet without named ranges

Next, double-click the form and paste the below code in the Code window:

Public SelectedWorkbook As String Private Sub UserForm_Initialize() SelectedWorkbook = "" ListBox1.Clear For Each wbk In Application.Workbooks ListBox1.AddItem (wbk.Name) Next End Sub Private Sub CommandButton1_Click() If ListBox1.ListIndex > -1 Then SelectedWorkbook = ListBox1.List(ListBox1.ListIndex) End If Me.Hide End Sub Private Sub CommandButton2_Click() SelectedWorkbook = "" Me.Hide End Sub

With the UserForm in place, you can use one of the following macros to copy the active sheet to the workbook of your choosing.

Copy sheet to the beginning of the selected workbook:

Public Sub CopySheetToBeginningAnotherWorkbook() Load UserForm1 UserForm1.Show If (UserForm1.SelectedWorkbook <> "") Then activeSheet.Copy Before:=Workbooks(UserForm1.SelectedWorkbook).Sheets(1) End If Unload UserForm1 End Sub

Copy sheet to the end of the selected workbook:

Public Sub CopySheetToEndAnotherWorkbook() Load UserForm1 UserForm1.Show If (UserForm1.SelectedWorkbook <> "") Then activeSheet.Copy After:=Workbooks( _ UserForm1.SelectedWorkbook).Sheets( _ Workbooks(UserForm1.SelectedWorkbook). _ Worksheets.Count) End If Unload UserForm1 End Sub

When run in Excel, the macro will show you a list of all currently opened workbooks. You select the needed one and click OK:

Copy Excel sheet without named ranges

Excel macro to copy sheet and rename

When you copy a sheet in Excel, the replica is given a name in the default format like Sheet1 (2). The following macros can spare you the trouble of changing the default name manually.

This code duplicates the active worksheet, names the copy as "Test Sheet" (you are free to replace it with any other name you like), and places the copied sheet at the end of the current workbook.

Public Sub CopySheetAndRenamePredefined() activeSheet.Copy After:=Worksheets(Sheets.Count) On Error Resume Next activeSheet.Name = "Test Sheet" End Sub

To allow the user to specify the name for the copied sheet, use this code:

Public Sub CopySheetAndRename() Dim newName As String On Error Resume Next newName = InputBox("Enter the name for the copied worksheet") If newName <> "" Then activeSheet.Copy After:=Worksheets(Sheets.Count) On Error Resume Next activeSheet.Name = newName End If End Sub

Upon running, the macro displays the following input box, in which you type the desired name and press OK:

Copy Excel sheet without named ranges

Excel macro to copy sheet and rename based on cell value

In some situations, it may be more convenient to name a copy with a specific cell value, for example, a column header. For this, you simply take the above code and supply the value of the currently selected cell to the input box automatically. As with the previous example, the copy will be placed at the end of the active workbook.

Copy Excel sheet without named ranges

The trickiest part would be to have your users always select the correct cell before running the macro :)

Public Sub CopySheetAndRenameByCell() Dim newName As String On Error Resume Next newName = InputBox("Enter the name for the copied worksheet", "Copy worksheet", ActiveCell.Value) If newName <> "" Then activeSheet.Copy After:=Worksheets(Sheets.Count) On Error Resume Next activeSheet.Name = newName End If End Sub

Alternatively, you can hardcode the address of the cell by which the copy should be named, cell A1 in the below code. To name the copied worksheet based on another cell, replace A1 with an appropriate cell reference.

Public Sub CopySheetAndRenameByCell2() Dim wks As Worksheet Set wks = activeSheet activeSheet.Copy After:=Worksheets(Sheets.Count) If wks.Range("A1").Value <> "" Then On Error Resume Next activeSheet.Name = wks.Range("A1").Value End If wks.Activate End Sub

Macro to copy worksheet to a closed workbook

This macro copies the active sheet to the end of a closed workbook. The name of another workbook is not specified in the code - the macro will open the standard Windows Explorer window and allow you to choose any destination file:

Copy Excel sheet without named ranges

After you select the file and click Open, the macro will copy the active sheet and close the target workbook automatically.

Public Sub CopySheetToClosedWorkbook() Dim fileName Dim closedBook As Workbook Dim currentSheet As Worksheet fileName = Application.GetOpenFilename("Excel Files (*.xlsx), *.xlsx") If fileName <> False Then Application.ScreenUpdating = False Set currentSheet = Application.activeSheet Set closedBook = Workbooks.Open(fileName) currentSheet.Copy After:=closedBook.Sheets(closedBook.Worksheets.Count) closedBook.Close (True) Application.ScreenUpdating = True End If End Sub

Excel VBA to copy sheet from another workbook without opening

This macro enables you to copy a worksheet from another Excel file without opening it. The copied sheet will be inserted at the end of the current workbook.

Just remember to make a couple of replacements in the code:

  • C:\Users\XXX\Documents\Target_Book.xlsx should be changed to the actual path and name of the workbook from which you want to copy a sheet.
  • Sheet1 should be replaced with the name of the sheet you want to copy.

Public Sub CopySheetFromClosedWorkbook() Dim sourceBook As Workbook Application.ScreenUpdating = False Set sourceBook = Workbooks.Open("C:\Users\XXX\Documents\Target_Book.xlsx") sourceBook.Sheets("Sheet1").Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) sourceBook.Close Application.ScreenUpdating = True End Sub

Excel VBA to duplicate sheet multiple times

Sometimes, you may need to duplicate the same sheet more than once, for instance to test different formulas on the same data set. This can be easily done with the following macro.

Public Sub DuplicateSheetMultipleTimes() Dim n As Integer On Error Resume Next n = InputBox("How many copies of the active sheet do you want to make?") If n >= 1 Then For numtimes = 1 To n activeSheet.Copy After:=ActiveWorkbook.Sheets(Worksheets.Count) Next End If End Sub

Open the original sheet, run the macro, specify how many copies of the active sheet you want to make, and click OK:

Copy Excel sheet without named ranges

How to duplicate sheets in Excel with VBA

To copy a sheet in Excel with one of the above macros, you can either insert the VBA code into your own book or run a macro from our sample workbook.

How to add a macro to your workbook

To insert the code in your workbook, perform these steps:

  1. Open the worksheet you want to copy.
  2. Press Alt + F11 to open the Visual Basic Editor.
  3. On the left pane, right-click ThisWorkbook, and then click Insert > Module.
  4. Paste the code in the Code window.
  5. Press F5 to run the macro.

For the detailed step-by-step instructions, please see How to insert VBA code in Excel.

How to run a macro from our sample workbook

Alternatively, you can download our sample workbook to Duplicate Excel Sheets and run the code from there.

The sample workbook contains the following macros:

CopySheetToNewWorkbook - copies the current worksheet to a new workbook.

CopySelectedSheets - copies multiple sheets that you select to a new workbook.

CopySheetToBeginningAnotherWorkbook - copies the active sheet to the beginning of another workbook.

CopySheetToEndAnotherWorkbook - copies the active sheet to the end of another Excel file.

CopySheetAndRename - duplicates the current sheet, renames it as specified by the user, and puts the copy after all other sheets in the current workbook.

CopySheetAndRenamePredefined - duplicates the active sheet, gives a hardcoded name to the copy and places it at the end of the current workbook.

CopySheetAndRenameByCell - makes a copy of the active sheet and renames it based on the selected cell value.

CopySheetAndRenameByCell2 - copies the active sheet and renames it based on the hardcoded cell address.

CopySheetToClosedWorkbook - allows you to copy sheet to a closed workbook.

CopySheetFromClosedWorkbook - enables you to copy a sheet from another Excel file without opening it.

DuplicateSheetMultipleTimes - lets you duplicate a sheet in Excel multiple times.

To run the macro in your Excel, just do the following:

  1. Open the downloaded workbook and enable the content if prompted.
  2. Open your own workbook and navigate to the sheet you want to copy.
  3. In your worksheet, press Alt + F8, select the macro of interest, and click Run.

Copy Excel sheet without named ranges

That's how you can duplicate a sheet in Excel with VBA. I thank you for reading and hope to see you on our blog next week!

You may also be interested in

How do you copy a worksheet in Excel without references?

How To Copy a Sheet to Another Workbook Without Links or References.
Save the workbook with a new name, then open the new one..
Click on the sheet you want to move, right-click then “Move or Copy.”.
On the “To book” drop-down menu, select “(new book)” then “OK.”.
The new one will open automatically..

How do you copy an Excel sheet without the data?

Simply hold down the Ctrl key, then click and drag the sheet's tab. When you release the mouse, Excel will create an exact copy of the sheet.

How do I copy a formula in Excel to another workbook without changing references?

Select the formula in the cell using the mouse, and press Ctrl + C to copy it. Select the destination cell, and press Ctl+V. This will paste the formula exactly, without changing the cell references, because the formula was copied as text.

How do you copy Excel sheet to another Excel file without losing layout and format Excel tutorial?

Here's how:.
Select all the data in the worksheet. Keyboard shortcut: Press CTRL+Spacebar, on the keyboard, and then press Shift+Spacebar..
Copy all the data on the sheet by pressing CTRL+C..
Click the plus sign to add a new blank worksheet..
Click the first cell in the new sheet and press CTRL+V to paste the data..