Reputation: 23
I have written for a button -
Private Sub CommandButton1_Click()
Dim path As String
Dim filename1\ As String
path = C:\Users\Barb\Desktop\demo\"
filename1 = Range("C4").Text
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename1=path & filename1 & ".xlsx",
FileFormatxlOpenXMLWorkbook
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub
How can I tell it when saving the sheet to use the title of the sheet tab
Upvotes: 0
Views: 20
Reputation: 1213
something like, for example:
filename1 = sheets(1).name
Or
filename1 = activesheet. name
Upvotes: 1
Reputation: 6418
Assuming you are talking about the ActiveSheet
, change:
filename1 = Range("C4").Text
to:
filename1 = ActiveSheet.Name
Upvotes: 1