![]() |
pass text attributes
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? |
pass text attributes
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 |
pass text attributes
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 |
pass text attributes
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 |
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 |
pass text attributes
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 |
pass text attributes
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 |
All times are GMT +1. The time now is 06:57 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com