如何根据单元格的所有可能值保存多个电子表格?

How to save multiple spreadsheets based on all possible values for a cell?

为了具体起见,例如,用户应在工作表 1 的 A1 单元格中输入 1 到 99 之间的值。然后重新计算 sheet2。

如何事先生成可能出现的所有不同 sheet2 的集合(带有值,不希望公式显示)?

如果您在 Sheet1 "A1" 中输入(比如说)99,那么 Sheet2 将在桌面上另存为 Sheet2_99.xlsx(根据需要更改路径),并按照 VBA Sheet1 中的以下步骤对象

Private Sub Worksheet_Change(ByVal Target As Range)
Application.DisplayAlerts = True
If Not Intersect(Range("A1"), Target) Is Nothing Then
    Sheets("Sheet2").Copy
    ActiveWorkbook.SaveAs Filename:="C:\Users\naresh\Desktop\Sheet2_" & Target.Value & ".xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

    With ActiveSheet.UsedRange
    .Value = .Value
    End With

ActiveWorkbook.Close True
End If

End Sub