How To Copy a column or columns from each sheet into one sheet using VBA in Excel?
Tags: tocopyacolumnorcolum, vbamacros
Published: 2021-09-29 09:28:14

---
title: How To Copy a column or columns from each sheet into one sheet using VBA in Excel?
published: true
date: 2021-09-27 11:42:59 UTC
tags: ToCopyAColumnOrColum,VBAMacros
canonical_url: https://geekexcel.com/how-to-copy-a-column-or-columns-from-each-sheet-into-one-sheet-using-vba-in-excel/
---

In this tutorial, we will guide you on how to  **copy a column or columns from each sheet into one sheet** using VBA in Excel. Let’s get them below!! Get an 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, you need to **create a sample data** that consists of **employee data** in the form of an Excel workbook containing **three sheets** with the **departmental, personal and contact details of employees**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Sample-data-45.png)<figcaption>Sample data</figcaption>

- To **copy data from different sheets into a new sheet** , you have to **create a macro CopyColumns** and this **macro** can be **run** by clicking the **Run macro button** on the **Main sheet**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Run-Macro.png)<figcaption>Run Macro</figcaption>

- 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://geekexcel.com/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.

```

Option Explicit
Sub CopyColumns()
Dim Source As Worksheet
Dim Destination As Worksheet
Dim Last As Long
Application.ScreenUpdating = False
'Checking whether "Master" sheet already exists in the workbook
For Each Source In ThisWorkbook.Worksheets
    If Source.Name = "Master" Then
        MsgBox "Master sheet already exist"
        Exit Sub
    End If
Next
'Inserting new worksheets in the workbook
Set Destination = Worksheets.Add(after:=Worksheets("Main"))
'Renaming the worksheet
Destination.Name = "Master"
'Looping through the worksheets in the workbook
For Each Source In ThisWorkbook.Worksheets  
    If Source.Name <> "Master" And Source.Name <> "Main" Then
        
        'Finding the last column from the destination sheet
        Last = Destination.Range("A1").SpecialCells(xlCellTypeLastCell).Column
        
        If Last = 1 Then
            'Pasting the data in the destination sheet
            Source.UsedRange.Copy Destination.Columns(Last)
        Else
            Source.UsedRange.Copy Destination.Columns(Last + 1)
        End If
    End If
Next
Columns.AutoFit
Application.ScreenUpdating = True
End Sub

```

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

![](https://geekexcel.com/wp-content/uploads/2021/09/Save-the-Code-83-1024x829.png)<figcaption>Save the Code</figcaption>

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

![Choose Macro option](https://geekexcel.com/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://geekexcel.com/wp-content/uploads/2021/09/Run-the-Code-52.png)<figcaption>Run the Code</figcaption>

- Finally, **CopyColumns macro** will **insert a new sheet** named as **Master** after the **Main sheet**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Output-42.png)<figcaption>Output</figcaption>

## End of Era

We hope that this tutorial gives you guidelines on how to  **copy a column or columns from each sheet into one sheet** using VBA in 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/) **!!**

**Read Next:**

- **[How to use the XNPV function in Excel office 365?](https://geekexcel.com/how-to-use-the-xnpv-function-in-excel-office-365/)**
- **[Excel Formulas to Highlight the Cells that End with Given Value!!](https://geekexcel.com/excel-formulas-to-highlight-cells-end-with/)**
- **[Excel Shortcut for “Select to End of Cell” in the Worksheet!!](https://geekexcel.com/quick-excel-shortcut-for-select-to-end-of-cell-in-a-worksheet/)**
- **[Shortcuts: Delete to the End of Line in the Spreadsheet!!](https://geekexcel.com/shortcuts-for-delete-to-the-end-of-line-in-ms-excel-365/)**
- **[Excel Formulas for Counting Cells that End with certain character or text!!](https://geekexcel.com/excel-formulas-for-counting-cells-that-end-with-certain-character-or-text/)**