View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default How do I retain formatting?

You have to be more specific when you ask your questions. Your original
message said...

"How can I adapt the above to retain the formatting from the source sheet?"

To answer the question you have now posed, you will have to tell us how the
text got colored... manually or via Conditional Formatting (CF)? If it was
colored manually, then you can do this...

Range("C20").Value = Range("C16").Value
Range("C20").Font.ColorIndex = Range("C16").Font.ColorIndex

If, on the other hand, the color came from CF, then you will need to perform
the same test(s) in code that you used in the CF and assign the appropriate
ColorIndex as per the test result(s).

--
Rick (MVP - Excel)



"Jock" wrote in message
...
That's better.
It copies comments also - can I narrow it down so it only copies the text
and the format the text is in (i.e bold or red)?
--
Traa Dy Liooar

Jock


"Rick Rothstein" wrote:

The default property for a range is Value, so your statement is only
assigning one value to another cell's value. If you use the range's Copy
method, then you bring everything about the cell over. Give this a try...

wbS.Range("E" & lngRowNo).Copy Wbd.Range("C" & lngNewRow)

--
Rick (MVP - Excel)



"Jock" wrote in message
...
The following line of code will copy data from one sheet (Wbs) to
another
(Wbd):

Wbd.Range("C" & lngNewRow).Value = wbS.Range("E" & lngRowNo)

How can I adapt the above to retain the formatting from the source
sheet?
--
Traa Dy Liooar

Jock


.