Results 1 to 5 of 5

Thread: Format lost after pasting range

  1. #1

    Thread Starter
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463

    Resolved Format lost after pasting range

    I lost my formatting after pasting a range from another sheet w/in a workbook into an other sheet. Here's my code:
    VB Code:
    1. shtSrc.Range("A1:Z10").Copy
    2.    shtDest.Range("A" & nS).PasteSpecial xlPasteAll
    3.    Set rangeX = shtDest.Range("A" & nS & ":L" & nE)
    I had successfully copied all the data and the formula except the formatting. Thanks in advance!
    Last edited by dRAMmer; Mar 1st, 2006 at 07:58 PM.
    live, code and die...

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Format lost after pasting range

    Looks like it should be pasting all which includes xlPasteFormats. If you change it from xlPasteAll to xlPasteFormats will it at least paste the formats that you have lost?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Format lost after pasting range

    dRAMmer ...

    Selection.Paste or Selection.PasteSpecial Paste:=xlPasteAll should copy the formatting from the source and override any previous formatting in the destination. Exactly what Format properties aren't getting copied correctly from the source to the destination?
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  4. #4

    Thread Starter
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463

    Re: Format lost after pasting range

    Hi Rob! If I will only use xlPasteFormats no data will be copied, so what I did is to xlPasteAll first then xlPasteFormats afterwards, still nothing happened.

    Webtest,
    Mostly column merging.

    Workaround: I don't want to do this as much as possible but if there's no solution for this, I will have to go to formatting the destination manually. Hope you can give some suggestions and possibly a solution. Thanks for the replies!
    live, code and die...

  5. #5
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Format lost after pasting range

    From my previous post ...
    Quote Originally Posted by Webtest
    dRAMmer ...
    ...
    Exactly what Format properties aren't getting copied correctly from the source to the destination?
    ...
    Are you dealing with CONDITIONAL formatting???
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

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



Click Here to Expand Forum to Full Width