I have several the same worksheets named "Copy Transposed" (Copy Transposed, Copy Transposed(2),Copy Transposed(3) etc.) I'd like to write a macro that will copy one Copy Transposed* worksheet with "Test1", "Test2", "Test3", "Test4", "Test5". So if I have 5 copy transposed worksheets I want to have 5 seperate files with copy transposed and "Test1", "Test2", "Test3", "Test4", "Test5". The name of the file should be the same as the name of the active worksheet. For instance I have 5 copy transposed worksheets so:
File 1- Copy Transposed.xlsm contains of "Copy Transposed", "Test1", "Test2", "Test3", "Test4", "Test5".
File 2- Copy Transposed(2).xlsm contains of "Copy Transposed(2)", "Test1", "Test2", "Test3", "Test4", "Test5".
File 3- Copy Transposed(3).xlsm contains of "Copy Transposed(3)", "Test1", "Test2", "Test3", "Test4", "Test5".
File 4- Copy Transposed(4).xlsm contains of "Copy Transposed(4)", "Test1", "Test2", "Test3", "Test4", "Test5".
File 5- Copy Transposed(5).xlsm contains of "Copy Transposed(5)", "Test1", "Test2", "Test3", "Test4", "Test5".
The number of "Copy Transposed" worksheets is always different
Sub test_macro()
Dim Fname As String
Fname = Sheets("Copy Transposed").Range("A1").Value
Sheets(Array("Test1", "Test2", "Test3", "Test4", "Test5")).copy
With ActiveWorkbook
ActiveWorkbook.SaveAs ThisWorkbook.path & "\" & Fname & ".xlsm", FileFormat:=52
End With
End Sub
path & ws.Name
to whatever you want. – braX