Hi, I am creating a VBA to create a new workbook and copy a worksheet into it. I have the following code I got off youtube, which works for the first time, but when I repeat it gets an error because the code says "book1" and new book is Book2 etc
Workbooks.Add
Windows("INSTANT RESULTS SPREADSHEET_MACRO_V5.1.XLSM").Activate
Sheets("REPORT").Select
Sheets("REPORT").Copy BEFORE:=Workbooks("BOOK1").Sheets(1)
I would also like to name the the new workbook from a combination of set term and a variable, the code I have for this is the following:
Dim FILENAME1 As String
Dim FILENAME2 As String
Dim FILENAME3 As String
FILENAME1 = "INSTANT RESULTS REPORT"
FILENAME2 = Worksheets("REPORT CREATOR").RANGE("G15")
FILENAME3 = Worksheets("REPORT CREATOR").RANGE("I15")
set Newbook = Workbooks.Add
with Newbook
- Title=filename1 & "-" & Filename2 "-" & filename3
I would like to do this all together if possible, create new workbook by the above naming and then copy a worksheet into it.
cheers Rob
Bookmarks