Open/Add New Workbook Macro Code

  • I am trying to write code to open a new (blank) workbook while in an existing workbook (I am then going to pass data between the two which is easy). When I try to record the code to get the syntax for opening a new workbook it will not record any code. I also need to name the new workbook based on text in a cell in the existing workbook. I just saw before posting this that the code;


    Code
    workbooks.add


    will open a new workbook now I just need to name the new workbook based on text in my existing workbook.

  • Re: Vba Code To Open A New Workbook


    Try this:

    Code
    Sub Save_Book()
    Dim MyBook As String, MyRange As Range
    MyBook = ThisWorkbook.Name
    Set MyRange = Workbooks(MyBook).Sheets("Sheet1").Range("A1")
        Workbooks.Add
        ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & MyRange.Value '_
           ActiveWorkbook.Close
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!