+ Reply to Thread
Results 1 to 12 of 12

Copy / PasteSpecial switches to other sheet

  1. #1
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Copy / PasteSpecial switches to other sheet

    The code below switches to Outsheet as soon as it hits the PasteSpecial line. I can make it work by adding "Sheets("InSheet").Select" after each PasteSpecial, but is that really necessary? Oddly, if I step through with the debugger, it works fine, but as soon as I hit F5, it switches sheets.

    Please Login or Register  to view this content.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Copy / PasteSpecial switches to other sheet

    Hi,

    If all you need is the values you can assign them directly
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Copy / PasteSpecial switches to other sheet

    It switches to the Outsheet on that line because that's where it is qualified.

    Please Login or Register  to view this content.
    The line in blue is qualified to the Sheets("OutSheet"), but the line before it (.copy) does not have a qualification. It will copy from the active sheet.
    Last edited by jeffreybrown; 03-19-2018 at 04:54 PM.
    HTH
    Regards, Jeff

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy / PasteSpecial switches to other sheet

    I understand that, Jeff. It is written as intended. But can't it paste to another sheet without actually selecting it?

  5. #5
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Copy / PasteSpecial switches to other sheet

    i attempted to replicate in excel 2010 and 2016 with a very simple macro... neither seemed to have that "feature"... but you might try
    Please Login or Register  to view this content.
    at the beginning of the code?
    Hope I could help - if your post has been solved don't forget to mark it as such.

    Clicking the * below is a great way to say thanks!

    "Drowning in 10 feet of water isn?t any different than drowning in a million feet. And if you can swim, it doesn?t matter how deep the ocean is. At some level, once you realize you?re in water that?s too deep to stand, you have to have a very different approach," - Joi Ito

  6. #6
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy / PasteSpecial switches to other sheet

    Thanks simarui, but I'm already doing that earlier. I just included the code with the problem.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Copy / PasteSpecial switches to other sheet

    Quote Originally Posted by natefarm View Post
    But can't it paste to another sheet without actually selecting it?
    Correct, you do not have to select the sheet to work with it. You just need to qualify where you want the output to show up.

    Did you try Don's suggestion?

  8. #8
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy / PasteSpecial switches to other sheet

    Not yet. I was hoping to figure out why mine didn't work first. Apparently it should. I tried this in a new workbook, copying from Sheet1, and it works fine, so there must be something I'm missing.

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy / PasteSpecial switches to other sheet

    Well, here's an odd thing. Below is a condensed version of the full code:

    Please Login or Register  to view this content.
    If I click in the LoadData subroutine and hit F5, it runs fine. I have a Command Button on a sheet assigned to LoadData, and when I click it, it doesn't work -- as soon as it hits the PasteSpecial line, it switches to OutSheet and stays there. I've proven this by putting a debug stop on the OutRw = OutRw + 1 line. When run directly, it's still in InSheet, but when run with the button, it's in OutSheet.

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Copy / PasteSpecial switches to other sheet

    I quite honestly don't know why it's behaving that way for you.

    Maybe you can fully qualify the sheets, that is, both sheets...

    Something like...

    Please Login or Register  to view this content.

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Copy / PasteSpecial switches to other sheet

    What kind of button is it and on which sheet is it located?

  12. #12
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy / PasteSpecial switches to other sheet

    I had actually already tried that, Jeff, but good suggestion.

    It is a Form control button on a different sheet that is assigned to LoadData in Module1. I had also tried moving the button to InSheet to no avail. So I switched to an ActiveX control, moved the code from LoadData to the click event, and it now works!!?

    Go figure. Thanks for your helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy PasteSpecial switches to the other sheet
    By natefarm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2018, 04:45 PM
  2. [SOLVED] Copy PasteSpecial fromon sheet to next sheet
    By arunabha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-31-2015, 03:51 AM
  3. Unprotect switches sheet
    By Maverickcool in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2010, 04:14 AM
  4. Replies: 1
    Last Post: 07-07-2009, 04:51 PM
  5. [SOLVED] Don't show sheet switches when running macro
    By Ben in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2005, 09:22 AM
  6. Filter Switches vs Sheet Protection?
    By Ken in forum Excel General
    Replies: 3
    Last Post: 02-23-2005, 06:06 PM
  7. Printing switches focus off proper sheet
    By Abi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-26-2005, 04:06 PM

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