Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Also look at Conditional Formatting. This can make the colors you want
without specific code. Glen |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sum (throw out highest and lowest) | Excel Worksheet Functions | |||
Indirect reference causes statistical function to throw up a #NUM! | Excel Worksheet Functions | |||
Make text color match cell color with macro? | Excel Discussion (Misc queries) | |||
How do I set up a formula to throw out the 2 lowest scores? | Excel Worksheet Functions | |||
How can I navigate throw multiple Web pages... | Excel Programming |