View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default pass text attributes

If you only have a few cells, this would work ok:

Option Explicit
Sub testme()
Dim iCtr As Long

With ActiveSheet
.Range("c3").Value = .Range("a1").Value
For iCtr = 1 To Len(.Range("a1").Value)
.Range("c3").Characters(Start:=iCtr, Length:=1).Font.FontStyle _
= .Range("a1").Characters(Start:=iCtr, Length:=1).Font.FontStyle
Next iCtr
End With

End Sub

But if you have lots and lots of cells (so lots of characters to inspect), this
type of thing can be really slow.

Dave Peterson wrote:

You could loop through each character in the sending cell and apply the
italicized format to the same character in the receiving cell.

But I would use copy|paste.

Is there a reason you don't want to use that?

Bert wrote:

That's part of the challenge with this: the whole cell is not italicised
only a few words out of the whole string.
Is there a way to preserve that?
Thanks.
Bert

"Dave Peterson" wrote in message
...
If you want to assign values, like:

.cells(a,b).value = .cells(c,d).value

Then you'll have to assign the formatting you want to keep:

.cells(a,b).value = .cells(c,d).value
.cells(a,b).Font.Italic = .cells(c,d).font.italic
(for italicizing the whole cell)

Bert wrote:

I want to copy text which includes some italicized text) from one cell to
another.
When I use the copy command, the italicized text is preserved, but when I
do
.Cells(a,b)=.Cells(c,d) the italics are lost.
Is there a way, using this method to carry the text formatting as well?

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson