How To Copy a sheet from each workbook into your workbook in a folder?
Tags: copyasheetfromeachwo, vbamacros
Published: 2021-10-21 02:18:02

---
title: How To Copy a sheet from each workbook into your workbook in a folder?
published: true
date: 2021-10-20 08:06:01 UTC
tags: CopyASheetFromEachWo,VBAMacros
canonical_url: https://geekexcel.com/how-to-copy-a-sheet-from-each-workbook-into-your-workbook-in-a-folder/
---

In this article, you will learn how to  **copy a sheet from each Workbook into your Workbook in a folder using VBA**  in Microsoft Excel. Let’s see them below!! Get the official version of  **MS Excel**  from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)

## Example

- Firstly, in the Excel Worksheet, you have to go to the  **Developer Tab.**
- Then, you need to ** ** select the  **Visual Basic**  option under the  **Code**  section.

![Select Visual Basic](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/09/Select-Visual-Basic-9-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to  **copy and paste the code**  given below.

```
Sub CopySheet()
Dim basebook As Workbook
Dim mybook As Workbook
Dim i As Long
    Application.ScreenUpdating = False
    With Application.FileSearch
        .NewSearch
        .LookIn = "C:\Data"
        .SearchSubFolders = False
        .FileType = msoFileTypeExcelWorkbooks
        If .Execute() > 0 Then
            Set basebook = ThisWorkbook
            For i = 1 To .FoundFiles.Count
                Set mybook = Workbooks.Open(.FoundFiles(i))
                    mybook.Worksheets(1).Copy after:= _
                    basebook.Sheets(basebook.Sheets.Count)
                    ActiveSheet.Name = mybook.Name
                mybook.Close
            Next i
        End If
    End With
    Application.ScreenUpdating = True
End Sub

```

- After that, you need to  **save the code**  by selecting it and then  **close the window**.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Save-the-Code-63.png)<figcaption>Save the Code</figcaption>

- Again, you have to go to the  **Excel Spreadsheet** , and click on the  **Developer Tab**.
- Then, you need to choose the  **Macros option**  in the Code section.

![Choose Macro option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/09/Choose-Macro-option-11-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Now, you have to make sure that your  **macro name is selected**  and click the  **Run ** button.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Run-the-Code-53.png)<figcaption>Run the Code</figcaption>

- After that, for this **sub(TestFile4\_values)** you must have unprotected worksheets, or unprotect them in the code.

```
Sub CopySheetValues()
    Dim basebook As Workbook
    Dim mybook As Workbook
    Dim i As Long
    Application.ScreenUpdating = False
    With Application.FileSearch
        .NewSearch
        .LookIn = "C:\Data"
        .SearchSubFolders = False
        .FileType = msoFileTypeExcelWorkbooks
        If .Execute() > 0 Then
            Set basebook = ThisWorkbook
            For i = 1 To .FoundFiles.Count
                Set mybook = Workbooks.Open(.FoundFiles(i))
                mybook.Worksheets(1).Copy after:= _
                                                 basebook.Sheets(basebook.Sheets.Count)
                ActiveSheet.Name = mybook.Name
                With ActiveSheet.UsedRange
                    .Value = .Value
                End With
                mybook.Close
            Next i
        End If
    End With
    Application.ScreenUpdating = True
End Sub

```

- You need to  **save the code**  by selecting it and then  **close the window**.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Ex-Save-the-Code-3-1024x597.png)<figcaption>Save the Code</figcaption>

- Now, you have to make sure that your  **macro name is selected**  and click the  **Run ** button.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Ex-Run-the-Code-2.png)<figcaption>Run the Code</figcaption>

- Finally, after running the macro, you will receive **a copy of a sheet from each Workbook** into your Workbook in a folder in Excel.

## Conclusion

We hope that this article gives you guidelines on how to  **copy a sheet from each Workbook into your Workbook in a folder ** using VBA in Microsoft Excel. ** ** Please leave a comment in case of any  **queries,**  and don’t forget to mention your valuable  **suggestions**  as well. Thank you so much for Visiting Our Site!! Continue learning on **[Geek Excel](https://geekexcel.com/)!! **Read more on [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

**Continue Reading:**

- **[How To Open Latest File in Folder in Excel office VBA?](https://geekexcel.com/how-to-open-latest-file-in-folder-in-excel-office-vba/)**
- **[How To Print all workbooks in a folder using VBA in Excel?](https://geekexcel.com/how-to-print-all-workbooks-in-a-folder-using-vba-in-excel/)**
- **[Open Containing Folder or Directory of Current Workbook in Excel](https://geekexcel.com/how-to-open-containing-folder-or-directory-of-current-workbook-in-excel/)**
- **[How to Copy a Formula in Excel Office 365 ~ Simple Guide!!](https://geekexcel.com/how-to-copy-a-formula-in-excel/)**