Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Dave.
There aren't too many cells to check. Actually it happens in a range of five cells per data entry session, so this would be managable. There's a complicating factor with the copy-paste solution. The cell the data is being copied to is actually in a different worksheet. When I first tested it, I just tried copying from one cell to the cell next to it. Copying to a different worksheet didn't carry the formating with it, even using the special paste method. So, I think I'll try to work with the subroutine you've included. Bert "Dave Peterson" wrote in message ... 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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the copy|paste again.
If your worksheets were in different workbooks and each of the workbooks were opened in separate instances of excel, you'll see that problem. But if you open both workbooks in the same instance, I bet you'll see what you want. Bert wrote: Thanks, Dave. There aren't too many cells to check. Actually it happens in a range of five cells per data entry session, so this would be managable. There's a complicating factor with the copy-paste solution. The cell the data is being copied to is actually in a different worksheet. When I first tested it, I just tried copying from one cell to the cell next to it. Copying to a different worksheet didn't carry the formating with it, even using the special paste method. So, I think I'll try to work with the subroutine you've included. Bert "Dave Peterson" wrote in message ... 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to pass text to web page ? | Excel Programming | |||
Data value display attributes linked to table attributes | Charts and Charting in Excel | |||
Pass text 255 char. to closed wkb with SQL? | Excel Programming | |||
Setting character attributes in a text string | Excel Worksheet Functions | |||
Different text attributes... | Excel Programming |