Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass text to web page ? moonhk Excel Programming 4 December 29th 06 05:14 AM
Data value display attributes linked to table attributes MDT at Paragon Home Inspections, LLC Charts and Charting in Excel 0 November 15th 06 12:53 AM
Pass text 255 char. to closed wkb with SQL? DB Excel Programming 1 December 9th 05 10:32 PM
Setting character attributes in a text string Greg Neill Excel Worksheet Functions 1 June 15th 05 08:47 PM
Different text attributes... rci Excel Programming 1 February 26th 04 07:12 PM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"