VBA Macro for font styles

  • Thread starter Thread starter GK80535
  • Start date Start date
G

GK80535

I'm trying to write a macro that toggles through font styles.

I'm trying to get the current font style and store it in a variable s
that I can reapply the original font style later after changing it
When I do this,

myVariable = activecell.font.color (to store the font color)

and later, I try to do this.

activecell.font.color = myVariable (to restore the font color)

The font in the activecell does not return to what was stored i
myVariable.

Can anyone help me out? Also, I used font.color in my example, but I'
actually interested in storing and restoring the entire font styl
(background color, font color, bold, italic, etc.)
 
Might be simpler just to Copy/Paste Special Formats the cell to some
off-the-screen holding cell.

--
Jim Rech
Excel MVP
|
| I'm trying to write a macro that toggles through font styles.
|
| I'm trying to get the current font style and store it in a variable so
| that I can reapply the original font style later after changing it.
| When I do this,
|
| myVariable = activecell.font.color (to store the font color)
|
| and later, I try to do this.
|
| activecell.font.color = myVariable (to restore the font color)
|
| The font in the activecell does not return to what was stored in
| myVariable.
|
| Can anyone help me out? Also, I used font.color in my example, but I'm
| actually interested in storing and restoring the entire font style
| (background color, font color, bold, italic, etc.).
|
|
| --
| GK80535
| ------------------------------------------------------------------------
| GK80535's Profile:
http://www.excelforum.com/member.php?action=getinfo&userid=15461
| View this thread: http://www.excelforum.com/showthread.php?threadid=270919
|
 
hi,
key phrase..."and later, i try to do this..."
variables disappear from memory when the macro ends. so if
you tried to call this variable to a new macro..... it's
not there anymore. so jim's suggestion is a good one.
regards
Frank.
 

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

Back
Top