So I am very new to VBA and coding and have been playing around writing very simple subs. The sub takes a sheet from a workbook, copies into a new workbook and then saves it. the problem is that I want to be able to specify the name it uses when it saves the document. I am using an input box, I just can't seem to get the code to accept the result. This is my code
Sub CC_Export()
Dim name As String
Dim Wb As Workbook
Set Wb = Workbooks("workbook1")
Wb.Sheets("Sheet1").Copy
name = InputBox("Enter Name of New Workbook", "New Workbook")
ActiveWorkbook.SaveAs "name.xlsx", FileFormat:=51
End Sub
Your code is using the literal text "name.xlsx". To use the variable you need to concatenate its value into your text string
ActiveWorkbook.SaveAs name & ".xlsx", FileFormat:=51
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With