+ Reply to Thread
Results 1 to 3 of 3

Split data in to multiple tabs using value in column

Hybrid View

Manpar Split data in to multiple... 05-03-2012, 08:51 AM
Bob Phillips Re: Split data in to multiple... 05-03-2012, 09:41 AM
Manpar Re: Split data in to multiple... 05-09-2012, 08:33 AM
  1. #1
    Registered User
    Join Date
    05-03-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question Split data in to multiple tabs using value in column

    Hello all,

    I have a data set in the worksheet "Master" with total of 6 columns at the more than 500 thousand rows. I want your help in splitting this data in to multiple tabs based on the values in column 4. I'm looking at the end result in this way, I have multiple tabs named by the value in column 4 and all the data points (6 columns) related to the name of the tab.
    Attached Files Attached Files

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Split data in to multiple tabs using value in column

    Try this

    Sub SplitData()
    Dim sh As Worksheet
    Dim lastCode As String
    Dim lastrow As Long
    Dim startrow As Long
    Dim i As Long
    
        With ActiveSheet
        
            lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
            .Range("A1").Resize(lastrow, 6).Sort key1:=.Range("D1"), order1:=xlAscending, Header:=xlYes
            For i = 2 To lastrow
            
                If .Cells(i, "A").Value <> lastCode Then
                
                    lastCode = .Cells(i, "D").Value
                    Set sh = .Parent.Worksheets.Add(after:=.Parent.Worksheets(.Parent.Worksheets.Count))
                    sh.Name = lastCode
                    startrow = i
                    Do While .Cells(i, "D").Value = lastCode
                    
                        i = i + 1
                    Loop
                    
                    .Rows(1).Copy sh.Range("A1")
                    .Rows(startrow).Resize(i - startrow).Copy sh.Range("A2")
                    
                    i = i - 1
                End If
            Next i
        End With
    End Sub

  3. #3
    Registered User
    Join Date
    05-03-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Split data in to multiple tabs using value in column

    Fantastic!! This works

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1