W
Wullie
Hi,
Is there a way to create a new workbook and give it a name (for referencing)
without saving the file?
I currently use SaveAs, but don't really need to keep the file.
However, I do need to jump between files so need to be able to reference
this new workbook.
It's probably something simple that I have overlooked, but any help would be
greatly appreciated.
My function is currently
Function NewWorkbookFunc(wsCount As Integer) As Workbook
' creates a new workbook with wsCount (1 to 255) worksheets
Dim OriginalWorksheetCount As Long
Set NewWorkbook = Nothing
If wsCount < 1 Or wsCount > 255 Then Exit Function
OriginalWorksheetCount = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = wsCount
Set NewWorkbook = Workbooks.Add
NewWorkbook.SaveAs Filename:=curPath & "\Comparison_" & Format(Date,
"yyyy_mm_dd")
Worksheets.Add().Name = "Comparison"
Application.SheetsInNewWorkbook = OriginalWorksheetCount
End Function
Can I just remove the SaveAs line and refer to NewWorkbook when activating
the new workbook?
Thanks
Is there a way to create a new workbook and give it a name (for referencing)
without saving the file?
I currently use SaveAs, but don't really need to keep the file.
However, I do need to jump between files so need to be able to reference
this new workbook.
It's probably something simple that I have overlooked, but any help would be
greatly appreciated.
My function is currently
Function NewWorkbookFunc(wsCount As Integer) As Workbook
' creates a new workbook with wsCount (1 to 255) worksheets
Dim OriginalWorksheetCount As Long
Set NewWorkbook = Nothing
If wsCount < 1 Or wsCount > 255 Then Exit Function
OriginalWorksheetCount = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = wsCount
Set NewWorkbook = Workbooks.Add
NewWorkbook.SaveAs Filename:=curPath & "\Comparison_" & Format(Date,
"yyyy_mm_dd")
Worksheets.Add().Name = "Comparison"
Application.SheetsInNewWorkbook = OriginalWorksheetCount
End Function
Can I just remove the SaveAs line and refer to NewWorkbook when activating
the new workbook?
Thanks