ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Font Object (https://www.excelbanter.com/excel-programming/382287-font-object.html)

Jack Clift[_3_]

Font Object
 
How do I set the font property of a cell / range to be the same as a
reference cell, without going through all the myriad of font properties and
setting individually

I have tried all manner of variations on the theme:

dim oFont as Font

set oFont = RefRange.Font
TargetCell.Font = oFont

Does not work and all manner of mucking around has not improved results

Thanks

Jack

Stefi

Font Object
 
Try this piece of code for copying format of cell A1 to B1:

Range("A1").Copy
Range("B1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Regards,
Stefi


€˛Jack Clift€¯ ezt Ć*rta:

How do I set the font property of a cell / range to be the same as a
reference cell, without going through all the myriad of font properties and
setting individually

I have tried all manner of variations on the theme:

dim oFont as Font

set oFont = RefRange.Font
TargetCell.Font = oFont

Does not work and all manner of mucking around has not improved results

Thanks

Jack


Peter T

Font Object
 
You can't copy the font object in one go. So other than PasteSpecial formats
as suggested by Stefi, which could also copy up to 30 other non font related
cell properties, you're stuck with setting font attributes individually.

Regards,
Peter T

"Jack Clift" wrote in message
...
How do I set the font property of a cell / range to be the same as a
reference cell, without going through all the myriad of font properties

and
setting individually

I have tried all manner of variations on the theme:

dim oFont as Font

set oFont = RefRange.Font
TargetCell.Font = oFont

Does not work and all manner of mucking around has not improved results

Thanks

Jack




Jack Clift[_3_]

Font Object
 
Thanks Stefi and Peter,

Can either of you provide an explanation as to why you cannot assign the
font object as per any other object? Just for my info?

Will use solution as suggested

Thanks for the timely reply

Regards

JC


"Peter T" wrote:

You can't copy the font object in one go. So other than PasteSpecial formats
as suggested by Stefi, which could also copy up to 30 other non font related
cell properties, you're stuck with setting font attributes individually.

Regards,
Peter T

"Jack Clift" wrote in message
...
How do I set the font property of a cell / range to be the same as a
reference cell, without going through all the myriad of font properties

and
setting individually

I have tried all manner of variations on the theme:

dim oFont as Font

set oFont = RefRange.Font
TargetCell.Font = oFont

Does not work and all manner of mucking around has not improved results

Thanks

Jack





Peter T

Font Object
 
Default property excepting, I can't think of any object type you can simply
assign to another object in the way you suggest, could you give an example
of what you had in mind.

Regards,
Peter T



"Jack Clift" wrote in message
...
Thanks Stefi and Peter,

Can either of you provide an explanation as to why you cannot assign the
font object as per any other object? Just for my info?

Will use solution as suggested

Thanks for the timely reply

Regards

JC


"Peter T" wrote:

You can't copy the font object in one go. So other than PasteSpecial

formats
as suggested by Stefi, which could also copy up to 30 other non font

related
cell properties, you're stuck with setting font attributes individually.

Regards,
Peter T

"Jack Clift" wrote in message
...
How do I set the font property of a cell / range to be the same as a
reference cell, without going through all the myriad of font

properties
and
setting individually

I have tried all manner of variations on the theme:

dim oFont as Font

set oFont = RefRange.Font
TargetCell.Font = oFont

Does not work and all manner of mucking around has not improved

results

Thanks

Jack








All times are GMT +1. The time now is 07:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com