One way to learn syntax is to record a macro. Here is the code recorded:
With Selection.Font
.Name = "Courier New"
.FontStyle = "Bold"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Selection.Interior
.ColorIndex = 14
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Recorded code is rarely complete. Not many, for example, would leave
..ColorIndex = 14 alone but would change the 14 to a variable name then
declare the variable. At the very least a comment would be added. Many of
the recorded lines *might* be eliminated.
To execute this code from a button.
Either add a button from the Control Tool box. Be sure to change the name
of the button. It is easier to understand what btnFormatFont does that if
the default name of CommandButton1 was kept. Then add a click event and
insert the recorded code.
Private Sub btnFormatFont_Click()
'Insert recorded code from above
End Sub
or
Add a button from the Forms toolbox and assign a macro. In this case you
will want to insert a module and create the macro first then add the button.
As always, rename your objects. Change the module name, the macro name, the
button name. This is not important in very short workbooks but it is a
habit you should consider learning.
good luck.
--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.
"nshanmugaraj"
wrote in message
news:nshanmugaraj.239s6m_1140005401.3076@excelforu m-nospam.com...
hi,
I am new to Excel programming...
can any one say how to write a macro to make a cell color = "green" and
the font = "bold" ... when cliking a button
i will be happy if you send me the coding since i am new to excel
programming
Thanks
N.ShRaj
--
nshanmugaraj
------------------------------------------------------------------------
nshanmugaraj's Profile:
http://www.excelforum.com/member.php...o&userid=31570
View this thread: http://www.excelforum.com/showthread...hreadid=512644