I am working on a form in excel with several macros. Currently, I have it set up so the user clicks a "save" button and the sheet they are working on saves to a specified file path under a new name as a new xls. The problem is that the macro buttons that I designed also transfer to the new wb since they are part of the sheet. I have tried and tried to just copy the range that contains the form but keep getting errors when I run the macro.
currently my code is this:
Sub Save_Macro()
Dim wb As Workbook
Dim NewShtName As String
Dim FilePath As String
FilePath = Sheets("inputs").Range("b36").Value
NewShtName = Range("E3")
ActiveSheet.Unprotect
Sheets("Form").Copy
Set wb = ActiveWorkbook
wb.Sheets("Form").Name = NewShtName
ActiveWorkbook.SaveAs (FilePath & NewShtName & "xls")
ActiveWorkbook.Close
ActiveSheet.Protect
End Sub
simple, i know. the range I need to copy from this sheet ("Form") is D2:V29.
Any ideas on how i can make this work?
also, I have tried sheets("Form").Range("D2:V29").Copy and it did not work for me.
currently my code is this:
Sub Save_Macro()
Dim wb As Workbook
Dim NewShtName As String
Dim FilePath As String
FilePath = Sheets("inputs").Range("b36").Value
NewShtName = Range("E3")
ActiveSheet.Unprotect
Sheets("Form").Copy
Set wb = ActiveWorkbook
wb.Sheets("Form").Name = NewShtName
ActiveWorkbook.SaveAs (FilePath & NewShtName & "xls")
ActiveWorkbook.Close
ActiveSheet.Protect
End Sub
simple, i know. the range I need to copy from this sheet ("Form") is D2:V29.
Any ideas on how i can make this work?
also, I have tried sheets("Form").Range("D2:V29").Copy and it did not work for me.