I'm trying to create a new workbook to save worksheets to. I create the new workbook, prompt for name. This all works, my problem is then I need to create a variable with that new name, so I can more easily jump back and forth when copying worksheets over to it.
Sub SaveInfo()
'
' SaveInfo Macro
'
Dim NWB As Workbook
Dim TWB As Workbook
Dim Fname As String
Dim MyTargetFile As Variant
Dim UserInput As Variant
Dim WBName As String
Workbooks.Add
MyOpenedFile = ActiveWorkbook.Name
'Here get a file name from user
UserInput = Application.InputBox(prompt:="Enter File name to save")
If UserInput <> "" Then
'Save the opened excel file by renaming it , here UserInput is used as new file name.
Workbooks(MyOpenedFile).SaveAs Filename:="G:\Clearwater\Archive Data\" & UserInput
End If
'Here I try to get that name of the new workbook
WBName = ThisWorkbook.Name
'Here I try to declare that workbook as a variable
Set NWB = Workbooks("WBName")
Set TWB = Workbooks("Historical Data Creation Tool ERIK New.xlsm")
This is where I will call that "New Workbook" NWB over and over again
TWB.Activate
Sheets("CW_AmortEarn").Select
Sheets("CW_AmortEarn").Copy Before:=NWB.Sheets(1)
TWB.Activate
Sheets("CW_FMV_FY").Select
Sheets("CW_FMV_FY").Copy Before:=NWB.Sheets(1)
I'm stuck. Perhaps there is a better way then what I'm trying to do here. Any ideas would be helpful.