+ Reply to Thread
Results 1 to 5 of 5

Paste problems with VBA code

  1. #1
    Registered User
    Join Date
    02-10-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Paste problems with VBA code

    I would appreciate some guidance on what may be wrong with the code below. Basically what I am trying to do is copy a date from one single cell then paste it into multiple cells depending on the space available. The error I get seems to indicate the problem is related to the paste range is a different size to the copy range, but not sure how to overcome this.

    Column A Column B
    row1 01/01/15 ABC
    row2 01/01/15 DEF
    row3 GHI
    row4 JKL
    row5 MNO

    The code is;
    Please Login or Register  to view this content.
    So if I had copied a date e.g. 15/07/15, then applying to example above I want this to be pasted into the range A3:A5.

    Any pointers would be most helpful.

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Paste problems with VBA code

    You don't have to use paste special, you only have to define the .value of the range. Try e.g.,

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-10-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Paste problems with VBA code

    Thanks berlan, that codes does work, is there anyway to incorporate a variable element to the date I am inserting as it won't always be the same date and won't always be copied from the same cell.

    For example I want to copy the date from another sheet and then paste it, I was thinking of some sort of 'relative' macro i.e. copy the selected cell, then execute your code?

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Paste problems with VBA code

    Define the output sheet name to make it more robust, so you can run it from another sheet.

    Another example, where you can define the cell to copy the value from -- here the first cell in your selection:

    Please Login or Register  to view this content.
    Hope this helps. Otherwise, feel free to upload an example workbook so that I can have a closer look.

  5. #5
    Registered User
    Join Date
    02-10-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Paste problems with VBA code

    Amazing, exactly what I was looking for, really appreciate the assistance.

+ 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. [SOLVED] Excel 2007 : Copy Paste problems
    By ruthbetts in forum Excel General
    Replies: 1
    Last Post: 06-12-2012, 07:52 AM
  2. VBA copy and paste problems
    By Sherpa21987 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2011, 11:33 PM
  3. Paste special problems...
    By DDmonk in forum Excel General
    Replies: 2
    Last Post: 02-11-2011, 09:44 AM
  4. copy and paste problems
    By paulplus_uk in forum Excel General
    Replies: 2
    Last Post: 06-03-2010, 05:09 AM
  5. Paste Problems
    By Buratti in forum Excel General
    Replies: 3
    Last Post: 02-03-2009, 03:55 PM
  6. copy paste problems
    By gpp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2008, 03:49 AM
  7. Problems with Copy/Paste Code
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-27-2008, 09:20 AM
  8. Problems with Paste
    By pwermuth in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2005, 01:05 AM

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