+ Reply to Thread
Results 1 to 8 of 8

Copy range from the worksheet preceding the active worksheet

  1. #1
    Registered User
    Join Date
    01-14-2013
    Location
    Maine
    MS-Off Ver
    Excel 2007
    Posts
    53

    Copy range from the worksheet preceding the active worksheet

    I need to copy a range of cells from a worksheet before the active worksheet. I can't use the name of the worksheet or its index number because these two things are always changing. So I need to reference the worksheet I want to copy from using only the active worksheet. My code looks like this:

    Please Login or Register  to view this content.
    So sheet "2" is my active and sheet "1" is the one I need the cells from. But I need to reference sheet 1 using the active sheet ("2")

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Copy range from the worksheet preceding the active worksheet

    The only way I can think of getting the previous sheet woud be to use the index of the current sheet and subtract one.

    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-14-2013
    Location
    Maine
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Copy range from the worksheet preceding the active worksheet

    I apologize, I figured it out. I was able to set both worksheets as variables like this:

    Please Login or Register  to view this content.
    Last edited by davidrias; 03-31-2013 at 07:42 PM. Reason: making easier to read

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Copy range from the worksheet preceding the active worksheet

    Oops, forgot about Previous and Next.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-14-2013
    Location
    Maine
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Copy range from the worksheet preceding the active worksheet

    I am not getting how I would do that by looking at your code. This copies from the active worksheet:

    Please Login or Register  to view this content.
    So how do you subtract 1 from the index?

    Thank you so much for your time.

  6. #6
    Registered User
    Join Date
    01-14-2013
    Location
    Maine
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Copy range from the worksheet preceding the active worksheet

    Oh perfect! Thanks, it seemed like a simple and reasonable thing to be able to do.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Copy range from the worksheet preceding the active worksheet

    Sorry it should have been this.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-14-2013
    Location
    Maine
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Copy range from the worksheet preceding the active worksheet

    Thank you I will tuck all of this away for future reference.

+ 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