Hello,
I have an excel file which is a dynamic dashboard. The values changes based on a check box list.
So on the dashboard sheet I have the stores in range B27 to B87. When I hit the box for one of them which is in range A27 to A87, the dahsboard updates itself by gathering datas from the other worksheet.
My objective is to create a code which will save as another excel file the dashboard of each store. I think I managed to do that but what I want to do additionnaly is to rename the name of the worksheet by the name of the store and I keep getting the error "the name is already take". Can you help me on this ?
The line causing the error is : Worksheets(1).Name=Sname
Thank you
I have an excel file which is a dynamic dashboard. The values changes based on a check box list.
So on the dashboard sheet I have the stores in range B27 to B87. When I hit the box for one of them which is in range A27 to A87, the dahsboard updates itself by gathering datas from the other worksheet.
My objective is to create a code which will save as another excel file the dashboard of each store. I think I managed to do that but what I want to do additionnaly is to rename the name of the worksheet by the name of the store and I keep getting the error "the name is already take". Can you help me on this ?
The line causing the error is : Worksheets(1).Name=Sname
VBA Code:
Sub ExportPDF()
Dim NamePDF As Worksheet
Dim path_PDF As String
Dim Sname As String
path_PDF = "path to folder"
Set NamePDF = ActiveWorkbook.Worksheets(1)
For i = 27 To 87
Cells(i, 1).Value = "True"
Sname = NamePDF.Cells(i, 2)
Worksheets(1).Name=Sname
ActiveWorkbook.SaveAs Filename:=path_PDF & "\" & Sname & ".xlsb", FileFormat:=xlExcel12
Cells(i, 1).Value = "False"
Next i
End Sub
Thank you