Creating tabs from column information

xbttyboopx

New Member
Joined
Aug 19, 2011
Messages
4
I have a spreadsheet that has one column with different department names. I need those names to transfer to another spreadsheet but as tabs so that each department has it's own tab, but keeping the information in tact that goes with each row. Is that possible?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hello & Welcome to the Board,

Try this...

You just need to click on the column you want to extract by...

Macro comes from this thread by VoG

Code:
Sub SplitOutSheets1()
    Dim LastRow As Long
    Dim iStart  As Long
    Dim iEnd    As Long
    Dim i       As Long
    Dim LastCol As Long
    Dim iCol    As Integer
    Dim ws      As Worksheet
    Dim r       As Range
    On Error Resume Next
    Set r = Application.InputBox("Click in the column to extract by", Type:=8)
    On Error GoTo 0
    If r Is Nothing Then Exit Sub
    iCol = r.Column
    Application.ScreenUpdating = False
    With ActiveSheet
        LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
        LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
        .Range(.Cells(2, 1), Cells(LastRow, LastCol)).Sort _
            Key1:=Cells(2, iCol), Order1:=xlAscending, Header:=xlGuess, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        iStart = 2
        For i = 2 To LastRow
            If .Cells(i, iCol).Value <> .Cells(i + 1, iCol).Value Then
                iEnd = i
                Sheets.Add After:=Sheets(Sheets.Count)
                Set ws = ActiveSheet
                On Error Resume Next
                ws.Name = .Cells(iStart, iCol).Value
                On Error GoTo 0
                ws.Range(Cells(1, 1), Cells(1, LastCol)).Value _
                        = .Range(.Cells(1, 1), .Cells(1, LastCol)).Value
                With ws.Rows(1)
                    .HorizontalAlignment = xlCenter
                    With .Font
                        .ColorIndex = 5
                        .Bold = True
                    End With
                End With
                .Range(.Cells(iStart, 1), .Cells(iEnd, LastCol)).Copy _
                        Destination:=ws.Range("A2")
                iStart = iEnd + 1
            End If
        Next i
    End With
    With Application
        .CutCopyMode = False
        .ScreenUpdating = True
    End With
End Sub
 
Last edited:
Upvote 0
This is code which goes into a normal module.

See this to read about placing code in your workbook

Once you place this code in the VBE, select Alt + F8 and then select SplitOutSheets1 and run
 
Upvote 0
Okay this works, but last question, when I have 3 tabs that need to be combined by this method into one new spreadsheet, is that possible?
 
Upvote 0
Hello I did not get an answer to my question on Friday. Can the formula given work on multiple spreadsheets each with multiple tabs?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top