Re: MSForms.DataObject Misbehaving

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




The DataObject's clipboard functions are limited to storing text
strings. Here's one way to swap the contents and formatting of two
cells, A1 and B1 in this case:

Dim R1 As Range
Dim R2 As Range
Dim Temp As Range
Dim WS As Worksheet
Set WS = ActiveSheet
Set R1 = Range("A1")
Set R2 = Range("B1")
With WS.UsedRange
Set Temp = .Item(.Cells.Count)(2, 1)
End With
R1.Copy Destination:=Temp
R2.Copy Destination:=R1
Temp.Copy Destination:=R2
Temp.Clear

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Sat, 27 Dec 2008 10:09:09 -0800 (PST), atpgroups
<bodgesoc@xxxxxxxxx> wrote:

On 27 Dec, 17:33, JLGWhiz <JLGW...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Excel default is to use the formatting of the receiving range.  To do what I
think you want to do, you would need to use a two step process. Step 1.
Range(x).Copy then Range(y).PasteSpecial Paste:=xlPasteFormats.  Step 2.
Range(y).PasteSpecial Paste:=xlPasteValues

The copy and pasting isn't the real issue, the problem is how to
_swap_ the values and formats. ie How can I store the formats in range
X when pasting Range Y into it.
.



Relevant Pages

  • Re: Excel Cell Formats
    ... Dim C1 As Range ... I am trying to swap two cells completely, with each other, including value, All formats, colors, etc. ...
    (microsoft.public.excel.programming)
  • Re: MSForms.DataObject Misbehaving
    ... _swap_ the values and formats. ... ie How can I store the formats in range ... X when pasting Range Y into it. ...
    (microsoft.public.excel.programming)
  • Re: Copy all formats and objects
    ... Dave Peterson wrote: ... Dim myShape as shape ... The problem with doing that is that every sheet has formulas that reference ... the formats except for the conditional formats, just the objects and a copy ...
    (microsoft.public.excel.misc)
  • Re: Copy all formats and objects
    ... Dim myShape as shape ... The problem with doing that is that every sheet has formulas that reference ... the formats except for the conditional formats, just the objects and a copy ... Dim TB As TextBox ...
    (microsoft.public.excel.misc)
  • Re: Hiding Data points Equal to Zero
    ... macro while applying the formats. ... Dim sr as Series ... I haven't bothered with the code, partly as it will depend on your chart ... but I wonder if you really need to hide your zero value points. ...
    (microsoft.public.excel.programming)