Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color Cell throw macro


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Color Cell throw macro

Try this bit of code, it uses the selected cells:

Sub MakeCellGreenAndBold()
' uses the selected cell
With Selection
With .Interior
.ColorIndex = 35 ' or try 4 or 50
.Pattern = xlSolid
End With
.Font.Bold = True
End With
End Sub

--

change
.ColorIndex = 35 ' or try 4 or 50
to be 4 or 50 for a different color.

You then have to insert a button and assign the macro.

Note if you want a specific cell change

With Selection
to
With ActiveSheet.Range("A1")

HTHs Martin


"nshanmugaraj" wrote:


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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Color Cell throw macro

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Color Cell throw macro

Also look at Conditional Formatting. This can make the colors you want
without specific code.

Glen

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color Cell throw macro


Hi
thanks for the code....
i am in specifically need to change the color of rows wihch satisfy a
condition

can u kindly help me please....


--
nshanmugaraj
------------------------------------------------------------------------
nshanmugaraj's Profile: http://www.excelforum.com/member.php...o&userid=31570
View this thread: http://www.excelforum.com/showthread...hreadid=512644



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Color Cell throw macro

Hi N,

See:

http://www.contextures.com/xlCondFormat02.html


---
Regards,
Norman



"nshanmugaraj"
wrote in message
news:nshanmugaraj.23av2m_1140055803.7723@excelforu m-nospam.com...

Hi
thanks for the code....
i am in specifically need to change the color of rows wihch satisfy a
condition

can u kindly help me please....


--
nshanmugaraj
------------------------------------------------------------------------
nshanmugaraj's Profile:
http://www.excelforum.com/member.php...o&userid=31570
View this thread: http://www.excelforum.com/showthread...hreadid=512644



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum (throw out highest and lowest) Timothy Garrison Excel Worksheet Functions 3 December 2nd 09 02:09 AM
Indirect reference causes statistical function to throw up a #NUM! JoCa Excel Worksheet Functions 10 July 23rd 09 10:11 AM
Make text color match cell color with macro? JoeSpareBedroom Excel Discussion (Misc queries) 1 June 26th 07 07:09 PM
How do I set up a formula to throw out the 2 lowest scores? Rineay Excel Worksheet Functions 1 June 15th 06 05:08 PM
How can I navigate throw multiple Web pages... Luc Dansereau[_3_] Excel Programming 0 May 14th 05 10:24 PM


All times are GMT +1. The time now is 10:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"