Dynamic Cell Format

C

cdil

Hello everyone,

I am creating a sub that takes the value of a range into another one as
a formula
i.e. Range("TargetCell").FormulaR1C1 "=SourceCell"
So it can be updated automatically when SourceCell changes.

I would like to know if it is possible to copy or get the format of the
SourceCell to apply it also to the TargetCell.

For example:
SourceCell value is "Hello John" with the word "John" in bold
characters.
Currently, TargetCell will display "Hello John" without the bold
characters.

How can I do to also get the word "John" in bold characters while
keeping the "dynamicity" of the cell ?

Thanks you for your help !
 
D

Dave Peterson

If you leave the formula in the cell, then you can't use this character by
character formatting.

If you could use values, you could copy|paste.
 
W

WhytheQ

if A1 is in bold but B1 isn't then you can do something like:

range("A1").copy
range("B1").pastespecial xlformats

Rgds
J
 
C

cdil

Thanks guy for your help :)
Unfortunatelly with a copy & paste (even by pasting only formats), I
can't preserve the "dynamicity" :(

Other ideas ?
 
D

Dave Peterson

If the original cell is changing because of typing, you could use a
worksheet_change event to do the copy|paste (and formats) for you.

If the original cell is changing because of a calculation/formula, then you
could use a worksheet_calculate event to do the copy|paste (and formats) for
you.

But both of these mean that the "receiving" cell will not contain a formula.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top