+ Reply to Thread
Results 1 to 11 of 11

Copy and paste Value and Format

  1. #1
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Copy and paste Value and Format

    Hello all, have an easy one today. I need to copy the value and format of a range of cells, is there a way to do this in one step rather this:
    Please Login or Register  to view this content.
    Thanks for your help everyone.
    Last edited by MrHockey; 06-22-2009 at 03:25 PM.

  2. #2
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Copy and paste Value and Format

    I figured this one out...do not qualify what is being copied and you get it all...
    I feel so stupid.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy and paste Value and Format

    Glad you got it, but the oneline answer you were asking about would be:

    Please Login or Register  to view this content.
    No need to really "set" the block or "select" the destination.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Copy and paste Value and Format

    Thanks J for that info, It provides yet another solution I was not aware of. When copying a cell, and since a cell can contain any of 3 attribute types (data; format; formula), it makes sense that VBA is able to provide 4 way sto manage these attributes (all; data only; format only; formula only). In code this would be:
    Please Login or Register  to view this content.
    ;
    Please Login or Register  to view this content.
    ;
    Please Login or Register  to view this content.
    ;
    Please Login or Register  to view this content.
    .
    And then per your help, to combine values and format you would use
    Please Login or Register  to view this content.
    .

    Thanks J for you help, much appreciated. This forum is super.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy and paste Value and Format

    Well, hold onto your hat, because you're only halfway there...

    Please Login or Register  to view this content.
    Truth is, if you want to get a full picture of the "paste special", in the regular worksheet click any cell, press CTRL-C, then click on EDIT > PASTE SPECIAL just to get this window open...look at ALL the fun things you can do with a pastespecial function...all that can be done in VBA, too.

  6. #6
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Copy and paste Value and Format

    I just tested "Range("D4").PasteSpecial xlPasteValuesAndNumberFormats" and it is not working. I have submitted a workbook with this posting, would you please review it and show me what I am doing wrong.

    Thanks again for the help.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Copy and paste Value and Format

    This post is in reply to "hold on to your hat"...

    I see what you mean J, I was just focused on the type of data that can exist in a cell, not the types of pastespecial. Thanks for the pointer. As you can see by my previous post I am still having trouble.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy and paste Value and Format

    You mucked up the copy command ranges, swapped the Sample1 and the target...that's why it's not working.

    Once you fix that, it WILL copy, but it still won't do what you want.

    To copy into cells with validation, I would keep ONE cell with validation in it handy for a followup copy / validation command.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 06-10-2009 at 10:44 PM.

  9. #9
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Copy and paste Value and Format

    Thanks for the help J. And sorry for the slow reply, have been super busy.

  10. #10
    Registered User
    Join Date
    09-19-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Copy and paste Value and Format

    Hi guys. Jbeau's oneline solution works fine for me; but how about doing the same thing from one sheet to another guys?


  11. #11
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Copy and paste Value and Format

    Hello Lee Calas, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

+ 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