Hi,

I have a workbook named 10001.xls (the number is an ID) and I need to duplicate it to hundreds of workbooks with names as 10002, 10003 and so on...

Therefore I use "VALUE(LEFT(RIGHT(CELL("filename",A1),13),5))" in order to write the filename without the extension on a cell and work with this ID as needed.

However, I believe there is a problem with my current code (being duplicate as well), as I soon as I create other files (e.g: 10002.xls) those try to open 10001.xls) or 10001.xls itself try to open 10002.xls . I am not sure what I am doing wrong as I need the VBA code on each workbook to be independent.

Please have a look to all the code I have.

Sheet1:

Private Sub cmdSave_Click()
ActiveWorkbook.Save
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Cells.Count > 1 Then Exit Sub
       If Not Intersect(Target, Range("C4:C10000")) Is Nothing Then
           With Target(1, 0)
               .Value = Date
           End With
       End If
End Sub
ThisWorkbook:

Option Explicit

Private Sub Workbook_Open()
Application.OnTime Now + TimeSerial(0, 10, 0), "saveIt"
Application.OnTime Now + TimeSerial(0, 5, 0), "AllWorkbookPivots"
End Sub
Module1:

Option Explicit
Sub saveIt()
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, FileFormat:=xlNormal

End Sub
Module2:

Option Explicit
Sub AllWorkbookPivots()
Dim pt As PivotTable
Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
    
        For Each pt In ws.PivotTables
                    pt.RefreshTable
        Next pt
        
    Next ws
    
End Sub
Does anyone know where it is the mistake that keeps calling other workbooks?

Thanks,
Ionatan