i will start my own thread rather than "hog" another thread
mr danteamor already created this macro to create workbooks
it will not overwrite an existing workbook. it will only create new ones
i need to adapt this code that every time its run, it searches for the workbook, if found it will update, if not found it will create
is that possible?
mr danteamor already created this macro to create workbooks
it will not overwrite an existing workbook. it will only create new ones
i need to adapt this code that every time its run, it searches for the workbook, if found it will update, if not found it will create
is that possible?
VBA Code:
Sub SplitIntoBooks()
Dim wb As Workbook, c As Range, ky As Variant
Dim lr As Long, lc As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheet1.Range("A1").AutoFilter
lr = Sheet1.Range("F" & Rows.Count).End(3).Row
lc = Sheet1.Cells(1, Columns.Count).End(1).Column
With CreateObject("scripting.dictionary")
For Each c In Sheet1.Range("F2:F" & lr)
.Item(c.Value) = Empty
Next
For Each ky In .Keys
Sheet1.Range("A1", Sheet1.Cells(lr, lc)).AutoFilter 6, ky
Set wb = Workbooks.Add(xlWBATWorksheet)
Sheet1.AutoFilter.Range.Copy
Range("A1").PasteSpecial xlPasteAll
wb.SaveAs ThisWorkbook.Path & "\" & ky
wb.Close False
Next
End With
Sheet1.ShowAllData
Application.ScreenUpdating = True
End Sub