I have a book with three worksheets: product, client, magazine. I need a macro assigned to a button in each of the sheets above. If the button is clicked by the user, then the active sheet should be saved as a new book with the following naming convention:
SheetName_ContentofCellB3_DD.MM.YYYY
Where
- The sheet name must be the name of the current active sheet
- ContentofCellB3 content of cell B3 active sheet every time
- DD.MM.YYYY current date
The following macro I wrote does the above:
Sub MyMacro()
Dim WS As Worksheet
Dim MyDay As String
Dim MyMonth As String
Dim MyYear As String
Dim MyPath As String
Dim MyFileName As String
Dim MyCellContent As Range
MyDay = Day(Date)
MyMonth = Month(Date)
MyYear = Year(Date)
MyPath = "C:\MyDatabase"
Set WS = ActiveSheet
Set MyCellContent = WS.Range("B3")
MyFileName = "MyData_" & MyCellContent & "_" & MyDay & "." & MyMonth & "." & MyYear & ".xls"
WS.Copy
Application.WindowState = xlMinimized
ChDir MyPath
If CInt(Application.Version) <= 11 Then
ActiveWorkbook.SaveAs Filename:= _
MyFileName, _
ReadOnlyRecommended:=True, _
CreateBackup:=False
Else
ActiveWorkbook.SaveAs Filename:= _
MyFileName, FileFormat:=xlExcel8, _
ReadOnlyRecommended:=True, _
CreateBackup:=False
End If
ActiveWorkbook.Close
End Sub
However, there are some problems that I would like to help you with:
- How can I change the above macro so that the user can decide the path where the new book will be saved?
- , , ?
- -
?
.
P.S. excel 2007 excel 2002