Trouble including paste special in macro

  • Hello,
    Wondering if there is anyway to include the paste formats and values into the below macro? Every time I try I get a Compile error, expected end of statement.


    Thanks


    Include This


    Code
    .PasteSpecial xlPasteFormats
    .PasteSpecial xlPasteValues




    Into this

    Code
    Sub TestGetValue2()
        GetData "C:\Test\ToBeCopied.xlsx", "Sheet1", "A1:D10", Sheets("Sheet1").Range("A1"), False, False
        
    End Sub
  • Re: Trouble including paste special in macro


    The below code is placed in a function module.




    Option Explicit

  • Re: Trouble including paste special in macro


    You need to explain. The additional code you posted uses ADO to get records using CopyFromRecordSet. There are no 'formats' to paste.

  • Re: Trouble including paste special in macro


    yes, you are correct. I guess I did cross post. I didn't know the two boards were ran and monitored by the same folks. Sorry

  • Re: Trouble including paste special in macro


    Quote from Grimes0332;768820

    You need to explain. The additional code you posted uses ADO to get records using CopyFromRecordSet. There are no 'formats' to paste.


    Thanks for the comment, as you can probably tell I really don't know much about vba (just learning some stuff).
    In my original dataset it has borders around the data and some of the cells has red text. I was just trying to find a way that when it copies the data to paste it with the original cell formatting. Thanks

  • Re: Trouble including paste special in macro


    As far as I'm aware, they're totally separate boards. But if you post the same issue on multiple boards and have multiple people replying, chances are some of those replies will be similar, if not identical. If that happens then someone has wasted their time - and that is the problem. Read this - http://www.excelguru.ca/content.php?184

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!