+ Reply to Thread
Results 1 to 2 of 2

Code for "Previuos WorkBook"?

  1. #1
    Registered User
    Join Date
    11-30-2005
    Posts
    12

    Code for "Previuos WorkBook"?

    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?

    Please Login or Register  to view this content.
    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

    Please Login or Register  to view this content.
    I would like to have

    Please Login or Register  to view this content.
    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

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Hi,
    You want excel to know what woorkbook you were just on?
    I have never seen it myself..
    Here's a cleaner code for pasting from one workbook to another,
    you can change the destination to a specific range, this code pastes to the first open cell after the last entry in column A..
    ActiveSheet.Range("A1:A5").Copy _
    Destination:=Workbooks("Book2").Sheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0)
    Last edited by davesexcel; 04-11-2008 at 07:36 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1