annieexcel
New Member
- Joined
- Jul 25, 2018
- Messages
- 22
Hi guys! I'm having some trouble with what I thought should be a pretty easy macro. I'm constantly working in a big workbook with many tabs. I want to be able to easily save a copy of the worksheet I am currently in and for the file to be named based off a cell reference. This code works when I'm in a workbook with only 1 tab but does not work in my workbook with many tabs. It does copy and create the file but the file just opens, and it doesn't save for me. Do you have any ideas? Any insight would be greatly appreciated.
Sub Make_And_Rename_Workbook()
Dim wksht As Worksheet
Set wksht = ActiveSheet
Dim path As String
path = "C:\Desktop"
wksht.Copy
ActiveWorkbook.SaveAs Filename:=path & wksht.Range("B3").Value & ".xlsx"
End Sub
Sub Make_And_Rename_Workbook()
Dim wksht As Worksheet
Set wksht = ActiveSheet
Dim path As String
path = "C:\Desktop"
wksht.Copy
ActiveWorkbook.SaveAs Filename:=path & wksht.Range("B3").Value & ".xlsx"
End Sub