+ Reply to Thread
Results 1 to 3 of 3

Copy/Paste only values

Hybrid View

  1. #1
    Registered User
    Join Date
    09-03-2004
    Posts
    9

    Copy/Paste only values

    Hey guys,

    How do I copy and paste values only in VBA using the .Copy method?

    My current code is listed below, but it does a normal copy/paste:
    Sheets("Inv").Rows(LSearchRow).Copy Sheets("CA").Rows(LCopyToRow)
    Thanks!

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copy/Paste only values

    To do that you need to break it into two lines like this:

    Sheets("Inv").Rows(LSearchRow).Copy 
    Sheets("CA").Rows(LCopyToRow).PasteSpecial xlValues
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Copy/Paste only values

    Hello Session101,

    You can do this two different ways. First, you can modify your copy statement to use PasteSpecial.
    Sheets("Inv").Rows(LSearchRow).Copy 
    Sheets("CA").Rows(LCopyToRow).PasteSpecial Paste:=xlPasteValues
    The second way is by direct assignment. This method only works with the Value property. Eventhough the Value property is the default property for a Range, you still must specify the property for the block transfer to work.
    Sheets("Inv").Rows(LSearchRow).Cells.Value = Sheets("CA").Rows(LCopyToRow).Cells.Value
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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