If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA Macro for font styles
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...o&userid=15461 View this thread: http://www.excelforum.com/showthread...hreadid=270919 |
#2
|
|||
|
|||
Might be simpler just to Copy/Paste Special Formats the cell to some
off-the-screen holding cell. -- Jim Rech Excel MVP "GK80535" wrote in message ... | | 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...o&userid=15461 | View this thread: http://www.excelforum.com/showthread...hreadid=270919 | |
#3
|
|||
|
|||
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. -----Original Message----- Might be simpler just to Copy/Paste Special Formats the cell to some off-the-screen holding cell. -- Jim Rech Excel MVP "GK80535" wrote in message ... | | 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...hreadid=270919 | . |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Styles & Formatting Task Pane Not Working? | Hubert | Formatting Long Documents | 2 | October 6th, 2004 05:50 AM |
Styles - hopefully the last question! | Tom Smith | New Users | 6 | May 9th, 2004 04:41 PM |
word error | mac | General Discussions | 1 | May 6th, 2004 08:14 AM |
Macro to assign styles? | Stacey | Formatting Long Documents | 3 | April 28th, 2004 04:09 AM |
Macro | Nicole | Worksheet Functions | 4 | October 9th, 2003 09:53 PM |