Consulting

Results 1 to 3 of 3

Thread: Solved: Paste Special between Worksheets

  1. #1
    VBAX Regular
    Joined
    May 2007
    Posts
    23
    Location

    Solved: Paste Special between Worksheets

    I must be missing something on syntax and could use some help with Paste Special-
    This code works to copy a cell between Worksheets, but brings the format over-

    Worksheets("Sheet1").Range("C1").Copy _
    Destination:=Worksheets("printout").Range("C3")

    I can copy values only on the same worksheet with the following and it works

    With Worksheets("printout")
    .Range("C3").Copy
    .Range("G3").PasteSpecial xlPasteValues
    End With

    But if I try to copy between worksheets using the format of the first example I get a runtime error 1004, if I take out the = sign (like in the second example that works within a sheet)I get compiler error. I know it must be syntax but every example I find doesn't seem to work

    Worksheets("Sheet1").Range("C1").Copy _
    Destination:=Worksheets("printout").Range("C3").PasteSpecial = xlPasteValues

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You must Paste with a separate line of code when using PasteSpecial

    [vba]Worksheets("Sheet1").Range("C1").Copy
    Worksheets("printout").Range("C3").PasteSpecial xlPasteValues
    [/vba]
    Last edited by mdmackillop; 05-30-2007 at 05:15 AM. Reason: = sign deleted
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    May 2007
    Posts
    23
    Location
    Thankyou,
    That did the trick. Is it just good practice to use "Destination", or is it only in certain circumstances, or overkill. I always use it but it seems to get me an error at times.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •