+ Reply to Thread
Results 1 to 14 of 14

Simple copy and paste macro

Hybrid View

  1. #1
    Registered User
    Join Date
    10-04-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    12

    Post Simple copy and paste macro

    Hi Guys,

    I have found a macro I have been using on my worksheet for a while now,

    I basically copy a value from a fixed location (cell A1) to another cell which has a fixed column ("C") but a variable row.

    The row number is stored in cell A2

    So if cell A2 contained the value 23, I want to copy the contents of A1 to cell C23.


    I have been using this code

    PHP Code: 
    Range("A1").Copy Destination:=Range("C" Range("A2").Value
    I would now like to paste the copyied cell to another sheet rather than in column "C"

    However I still want the range to be dictated by "A2"


    Can this be done?

    Thanks for your help
    Hernan
    Last edited by hernancrespo; 11-08-2012 at 05:46 AM. Reason: Rude post

  2. #2
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Simple copy and paste macro

    What should be destination sheet name and column?

  3. #3
    Registered User
    Join Date
    10-04-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Simple copy and paste macro

    Hi Sindhus,

    The destination sheet name should be "Week 1" and the column D

    Sorry I should of thought of this when I posted!

  4. #4
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Simple copy and paste macro

    Try this
     Range("A1").Copy Destination:=Sheets("Week 1").Range("D" & Range("A2").Value)

  5. #5
    Registered User
    Join Date
    10-04-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Simple copy and paste macro

    Alas! no

    I get this error?

    111111.JPG

    "Run-time error "1004"

    copy method of range class failed"

    When I click Debug it highlights the whole line
    Last edited by hernancrespo; 11-08-2012 at 06:50 AM.

  6. #6
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Simple copy and paste macro

    Which sheet is the cell A2 that you are referencing on and what is the name of the sheet you are copying from?
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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