A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

VBA Macro for font styles



 
 
Thread Tools Display Modes
  #1  
Old October 20th, 2004, 06:40 PM
GK80535
external usenet poster
 
Posts: n/a
Default 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  
Old October 20th, 2004, 07:04 PM
Jim Rech
external usenet poster
 
Posts: n/a
Default

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  
Old October 20th, 2004, 07:39 PM
Frank Stone
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 01:26 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.