• Ask a Question
150
Insert Image Size must be less than < 5MB.
    Ask a Question
    Cancel
    150
    More answer You can create 5 answer(s).
      Ask a Poll
      Cancel
      Expert

      Help me modify the VBA code to create only workbook with data.

      I have a workbook with the following worksheets “PreviousFN”, “CurrentFN”, “OmittedMbrs”, “NewMbrs”, “CommonEID” , “PayPeriod”, “Section” and “ImportHere”

      I want to split this workbook create workbooks but I don’t want to create all the workbooks. I want to create “PreviousFN”, “CurrentFN”, “OmittedMbrs”, “NewMbrs” and “CommonEID” only and only if they have data in each worksheet. They all have headings.

      The present code is creating workbooks of all the sheets. I don’t want to create “PayPeriod”, “Section” and “ImportHere”. “CommonEID” does not have the data.

      Please, I need help to modify the code to do so.

      Sub SplitWorkBook()
      '
      'SplitWorkBook
      '
      Dim xPath As String
      Dim xWs As Worksheet
      xPath = Application.ActiveWorkbook.Path
      Application.ScreenUpdating = False
      Application.DisplayAlerts = False
      For Each xWs In ThisWorkbook.Sheets
      xWs.Copy
      Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xls" '<< hardcoded the folder
      Application.ActiveWorkbook.Close False
      Next
      Application.DisplayAlerts = True
      Application.ScreenUpdating = True
      End Sub
      

      Asked by raghuprabhu on May 3, 2017 in Excel.
      0 Answers