Results 1 to 4 of 4

Thread: Multiple sheet splitting

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Junior Member
    Join Date
    Oct 2016
    Posts
    3
    Rep Power
    0
    thanks a lot for your help i have attached the out put required and the same has been resolved as per below macro

    Code:
    Sub SplitData()
        Dim wbk As Workbook
        Dim wsh As Worksheet
        Dim r As Long
        Dim m As Long
        Dim col As New Collection
        Dim v As Variant
        Dim s As String
        On Error Resume Next
        For Each wsh In ThisWorkbook.Worksheets
            m = wsh.Range("A" & wsh.Rows.Count).End(xlUp).Row
            For r = 4 To m
                col.Add Item:=wsh.Range("A" & r).Value, Key:=wsh.Range("A" & r).Value
            Next r
        Next wsh
        On Error GoTo 0
        Application.Cursor = xlWait
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        For Each v In col
            ThisWorkbook.Worksheets.Copy
            Set wbk = ActiveWorkbook
            For Each wsh In wbk.Worksheets
                m = wsh.Range("A" & wsh.Rows.Count).End(xlUp).Row
                For r = m To 4 Step -1
                    If wsh.Range("A" & r).Value <> v Then
                        wsh.Range("A" & r).EntireRow.Delete
                    End If
                Next r
                    If wsh.Range("A4").Value = "" Then wsh.Delete
                Next wsh
                
                s = ThisWorkbook.Path & "\" & v & ".xlsx"
              wbk.SaveAs Filename:=s, FileFormat:=xlOpenXMLWorkbook
            wbk.Close
        Next v
        Application.DisplayAlerts = True
        Application.ScreenUpdating = True
        Application.Cursor = xlDefault
    End Sub
    Attached Files Attached Files

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2019, 05:35 PM
  2. Replies: 2
    Last Post: 07-20-2017, 07:32 AM
  3. Splitting userform text onto different rows
    By achar in forum Excel Help
    Replies: 1
    Last Post: 02-21-2015, 07:04 PM
  4. Splitting and merging files with VBA
    By tryingtocode in forum Excel Help
    Replies: 1
    Last Post: 05-23-2013, 10:37 PM
  5. Combine Columns From Multiple Sheets To One Sheet
    By Portucale in forum Excel Help
    Replies: 6
    Last Post: 04-24-2013, 09:18 PM

Posting Permissions

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