loop through all files in a folder divide each worksheet into workbooks by date

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
672
Office Version
  1. 365
Platform
  1. Windows
600+ 1 page workbooks in a folder
sheet 1 (i tried worksheet.name = ky) has many entries all with different dates
how can i loop through each workbook
divide the new workbook into as many worksheets (tabs) as months (column E)
please advise
also if i run the macro again will i need it to override and update the workbooks - NOT create new ones unless a name is missing
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
hi
i got the first part i divided master into many 1 sheet workbooks
how do i fix this so that:
1- master remains visible - it filters it all out
2- more important, i need to now loop through all these newly created workbooks to divide them into workbooks with tabs filtered by column E (date) and name the tabs by date
can anyone help me?

VBA Code:
Sub Split_to_Participants()
  Dim sh As Worksheet, c As Range, ky As Variant, wb As Workbook, wPath As String, lr As Long
  Application.SheetsInNewWorkbook = 1
  Application.ScreenUpdating = False
  Application.DisplayAlerts = False
  Set sh = ActiveSheet
  wPath = "M:\all\FI Payments\Single Participant Payment Worksheets\"
  If sh.AutoFilterMode Then sh.AutoFilterMode = False
  lr = sh.Range("A" & Rows.Count).End(xlUp).Row
  With CreateObject("scripting.dictionary")
    For Each c In sh.Range("B2:B" & lr)
      .Item(c.Value) = Empty
    Next
    For Each ky In .Keys
      sh.Range("B1").AutoFilter 2, ky
      Set wb = Workbooks.Add
      sh.AutoFilter.Range.EntireRow.Copy Range("A1")
      wb.SaveAs ky
      Worksheet(1).Name = ky
      wb.Close False
    Next
  End With
  sh.ShowAllData
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,323
Members
449,077
Latest member
jmsotelo

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