+ Reply to Thread
Results 1 to 5 of 5

Paste in Worksheet without choosing the worksheet

  1. #1
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Paste in Worksheet without choosing the worksheet

    Hello all,

    I am trying to write a macro that pastes data from one tab to another, while only selecting certain information to paste. Currently, the code will only work if I have the tab that I want to paste information into selected. I would like the code to paste data into the worksheet even though it will not be selected. Below is the code.

    Please Login or Register  to view this content.

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

    Re: Paste in Worksheet without choosing the worksheet

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

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,962

    Re: Paste in Worksheet without choosing the worksheet

    Please Login or Register  to view this content.
    Last edited by protonLeah; 12-18-2012 at 10:39 PM.
    Ben Van Johnson

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Paste in Worksheet without choosing the worksheet

    I'm pretty sure it's CELLS that is a VBA reserved word, CELL is safe to use, though it certainly walks right up to the line, doesn't it?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Re: Paste in Worksheet without choosing the worksheet

    @ Norie, Your code worked like a charm, but I tried to use protonLeah's code first, because I like how the destination range was not specifically defined. The only problem with protonLeah's code was that I kept on getting a "Runtime error 1004", and I think it was because I was trying to copy a whole row.

    @protonLeah, is there a way for me to avoid the "Runtime Error 1004" by not copying the whole row?

    @JBeaucaire, I agree, I changed the object name to "SiteID".

    I modified the SiteCol dimension to refer to a named range, that I defined through the regular worksheet options. And, I did some research on the "Runtime Error 1004"; and it's basically saying that there's an error that VB does not know how to define. So, I'm exploring options on how to only choose part of the row that the value "Unkown" is found on.

    Below is the code.

    Please Login or Register  to view this content.
    I've been doing a lot of updating, so I think my problem is, is that the target
    Please Login or Register  to view this content.
    is causing the runtime error, and I can't find an alternative way to define the target range to be just columns A:U within the same row as where the cell object finds the value "Unkown". I am getting somewhere?
    Last edited by Bob1980; 12-19-2012 at 01:54 PM.

+ 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