+ Reply to Thread
Results 1 to 5 of 5

Paste Values

Hybrid View

  1. #1
    Registered User
    Join Date
    07-30-2010
    Location
    Warrington, England
    MS-Off Ver
    Excel 2010
    Posts
    71

    Red face Paste Values

    Hi,

    I have a piece of code I'm using to copy some values that are an external data table. How would I modify this so that, when I copy and paste, I only paste the values?

    With Workbooks(Scoresheet).Worksheets("DataTable")
              LastRow = .Range("P" & .Rows.Count).End(xlUp).Row
              .Rows("1:" & LastRow).Copy Workbooks(Scoresheet).Worksheets("Imported").Range("A" & LastRow)
               Application.CutCopyMode = False
           End With
    Many thanks in anticipation

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Paste Values

    change
    .Rows("1:" & LastRow).Copy Workbooks(Scoresheet).Worksheets("Imported").Range("A" & LastRow)
    to
    .Rows("1:" & LastRow).Copy 
    Workbooks(Scoresheet).Worksheets("Imported").Range("A" & LastRow).PasteSpecial xlpastevalues
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    07-30-2010
    Location
    Warrington, England
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Paste Values

    Many thanks. That's what I thought but when I run the code I then get an error message 1004, Unable to get the Pastespecial property of the Range Class.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Paste Values

    is the target sheet protected? what is the value of lastrow?

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Paste Values

    You have used the Lastrow variable for both the source and destination. Are they having the same number of rows?

    Or else you can use
    Workbooks(Scoresheet).Worksheets("Imported").Range("A" & LastRow).PasteSpecial (xlpastevalues)
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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