Can someone help with the following code problem?
I have 2 open files (WorkBooks).
I am writing code, to go from one to the other (the "other" has a known name). In this other I will copy a range of cells. These cells are to pasted into a specific sheet in THE FIRST WORKBOOK (which WorkBook has an UNKNOWN NAME).
I have no problem going from the first to the other and copying the range I want, but how do I get back to the first WorkBook?
Range("A1").Select 'In the first WorkBook
Windows("The Other.xls").Activate 'To the other
Sheets("A").Select
Range("A1:B5").Select
Selection.Copy
Range("A1").Select
Application.ScreenUpdating = True
ActiveWindow.ActivatePrevious 'See explanation
Worksheets("B").Activate
Range("A1").Select
ActiveSheet.Paste
This code actually works for the situation described, but if I have 2 identical WorkBooks (with different names) open plus "the other" WorkBook, with the known name and the source of the range I want to copy, then it jumps back to the second of the identical WorkBooks. Not to the one WorkBook in which I activated the code.
Instead of
ActiveWindow.ActivatePrevious
I would like to have
ActiveWorkBook.ActivatePrevious
But this does not work.
Is there a way to come back to the WorkBook from which I activated the code?
I would be greatful for some tips.
Thanks in advance
Ulfah
Bookmarks