+ Reply to Thread
Results 1 to 18 of 18

Why does my xlPasteValues past blanks?

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Why does my xlPasteValues past blanks?

    Hi,

    I have searched the web and this forum for the proper syntax but nothing has worked for me thus far.

    I dim and set 2 ranges, and do a copy and paste from one to the other:

    Exp314a.Copy
    Exp314b.PasteSpecial

    When I use the above code, I can see the formulas in the cells, but when I use any of the following code to paste values instead of formulas, I get blank cells instead:

    Exp314b.PasteSpecial :=xlPasteValues

    Exp314b.PasteSpecial xlPasteValues

    Exp314b.PasteSpecial (xlPasteValues)

    Can you point me in the right direction?

    Thanks.

    Brian
    Last edited by Brian48072; 12-17-2012 at 04:52 PM.

  2. #2
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: Why does my xlPasteValues past blanks?

    Hi Brian,

    Welcome to the forum, There could be quite a few reasons for this, Can you share the entire code please?

    Thanks.
    If solved kindly remember to mark Thread as solved.
    Click the small star icon at the bottom left of my post if this was useful.

  3. #3
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Why does my xlPasteValues past blanks?

    Have you tried this:

    Exp314b.PasteSpecial Paste:=xlPasteValues

    - Moo
    Last edited by Moo the Dog; 12-17-2012 at 12:02 PM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Why does my xlPasteValues past blanks?

    Hi Brian, and welcome to the forum.

    Your third option works perfectly well for me. Perhaps you'd better upload your workbook so we can see your request in context.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    Thanks for the response kbkumar.

    Here is the code:

    Dim Exp314a As Range
    Set Exp314a = Range(Cells(2, 28), Cells(2, 28))

    Exp314a.FormulaR1C1 = _
    "=IF(RC[7]="""","""",IF(RC[7]=""BP"",RC[-1],VLOOKUP(RC[-1],Export4A!R2C4:R500C5,2,FALSE)))"

    'Please note: I only close the Export4A file referred to in the Vlookup after I attempt the paste to values. (I always leave it open when I do just a paste so i can see the formulas).



    Dim Exp314b As Range
    Set Exp314b = Range(Cells(3, 28), Cells(LastRowB, 28))

    Exp314a.Copy
    Exp314b.PasteSpecial (xlPasteValues)


    '.PasteSpecial xlPasteValues
    '.PasteSpecial (xlPasteValues)
    ''PasteSpecial:=xlPasteValues




    'Exp314b.PasteSpecial
    '.PasteSpecial

  6. #6
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    Hi Moo,

    I still get blanks with Exp314b.PasteSpecial Paste:=xlPasteValues

    Brian

  7. #7
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    Hi Richard,

    Is this the version that worked for you: Exp314b.PasteSpecial (xlPasteValues) ?

    Brian

  8. #8
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: Why does my xlPasteValues past blanks?

    Changing the paste line to:

    Exp314b.PasteSpecial Paste:=xlPasteValues

    (as also advised by Moo) seems to work fine.

    May be you need to upload your workbook to have a closer look....

  9. #9
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    How do I upload my workbook?

  10. #10
    Forum Contributor
    Join Date
    09-27-2012
    Location
    London, England
    MS-Off Ver
    2003, 2010
    Posts
    344

    Re: Why does my xlPasteValues past blanks?

    To attach a file, click on "Go Advanced" below the post and the click on Attachments, browse to the required file, and then push the Upload button.

  11. #11
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    Thanks, I tried to upload the workbook, but even with it zipped it is over 4 mb's. I guess this is the end of the trail. Thanks to everyone who tried to help me.

    Brian

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

    Re: Why does my xlPasteValues past blanks?

    check the sheet before the paste special step happens-are the formulas evaluating to ""?
    Josie

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

  13. #13
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    Joseph,

    When I just use:

    Exp314a.Copy
    Exp314b.PasteSpecial

    I see the formulas populate all cells in the target range and produce the proper values, including blanks in some but not all cases.

    Brian

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

    Re: Why does my xlPasteValues past blanks?

    do the formulas work in the source range? those are the values you're pasting not the values the formulas would have if you pasted them into the target range. if that's what you need you have to paste the formulas then copy those and paste special values

  15. #15
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    Yes, the formula works in the source range, which is the first cell below the column header.

    Then when I use code to copy the source down to the bottom of the same column, the formulas all appear and evaluate properly. But when I try to use paste values, I get all blanks other than in the source cell.

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

    Re: Why does my xlPasteValues past blanks?

    if you copy one cell and paste special values down the column you will just get the value of that cell in every cell in the column

  17. #17
    Registered User
    Join Date
    09-10-2012
    Location
    Berkley, Michigan USA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Why does my xlPasteValues past blanks?

    Yes Joseph - you are right. I coded a subsequent Copy-Paste-Special-Values on the entire range after the initial Copy-Paste that populated the range with formulas, and it worked. I couldn't see that myself until you mentioned it.

    Thanks so much!

    Brian

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

    Re: Why does my xlPasteValues past blanks?

    you're welcome :-)

    please don't forget to mark the thread solved

+ 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