Link to home
Start Free TrialLog in
Avatar of Justincut
Justincut

asked on

How to switch between windows in Excel when the path is referenced in a Excel cell?

Hi Guys, I have an Excel Macro which opens a spreadsheet in the Cell "F7", then copies and pastes to another spreadsheet. See the code below. However, when I go Windows -> (so to return to the spreadsheet) how do I adapt  it in the code?

Sub Macro9()

    Workbooks.Open Filename:=Range("F7")

    Sheets("CV").Select
    Cells.Select
    Range("A17").Activate
    Selection.Copy
    Windows("01 - EMEA Mortgages Reporting Pack - Jan 15 (B) Test.xlsm").Activat
Avatar of Saurabh Singh Teotia
Saurabh Singh Teotia
Flag of India image

Sub macro9()
Dim wb As Workbook, wb1 As Workbook

Set wb = ThisWorkbook

Set wb1 = Workbooks.Open(Range("F7").Value)

    Sheets("CV").Select
    Cells.Select
    Range("A17").Activate
    Selection.Copy
    
    wb.Activate

Open in new window


You can use the following code...

Saurabh...
ASKER CERTIFIED SOLUTION
Avatar of Phillip Burton
Phillip Burton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You don't actually need to select or activate anything to copy ranges. What is the full purpose of the macro?