Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Conditional Formatting in a Macro

Hello I have the following Macro:

Sub Comma()
Range("K3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Style = "Comma"
End Sub

How can I add maybe after Selection.Style a line into this Macro with a
Conditional Formating that IF $B3 is equal to "1" then I want to have a Black
cell shading and White Arial Bold font style.

thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default Conditional Formatting in a Macro

Hi Ed,

If you want to add conditionnal formatting with your macro
Selection.FormatConditions.Add

If you want to test Range("B3").Value and then apply format changes
With Selection.Interior
.ColorIndex = 1
End With
With Selection.Font
.Name = "Arial Narrow"
.FontStyle = "Normal"
.ColorIndex = 2
End With


HTH
Carim

  #3   Report Post  
Posted to microsoft.public.excel.misc
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Conditional Formatting in a Macro

Hello Carim, sorry I didn't got how this code that you sent me works!
Anyways... I think I didn't explain myself well on the previous post... the
idea is to have a macro which takes "$K$3" from the sheet and my idea was to
drag a Conditional Formatting up to the Last Row and Column of that Table, I
already have it set up to give a "Comma" format, but I would like to add the
CF I mentioned before. The formula for the CF would be =$B3=1, What I mean
with that is that if $B3 has "1" in it, the entire row 3 would be black and
so on... but if $B4 doesn't have "1", the entire row stays as it is, and so
on...

This code:

Range("K3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Style = "Comma"
End Sub

I got it just though a simple "Record Macro", but I would like to add the
CF part into it...

thanks again!







"Carim" wrote:

Hi Ed,

If you want to add conditionnal formatting with your macro
Selection.FormatConditions.Add

If you want to test Range("B3").Value and then apply format changes
With Selection.Interior
.ColorIndex = 1
End With
With Selection.Font
.Name = "Arial Narrow"
.FontStyle = "Normal"
.ColorIndex = 2
End With


HTH
Carim


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
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Deferring conditional formatting? Pheasant Plucker® Excel Discussion (Misc queries) 14 March 17th 06 08:17 PM
cannot use ISEVEN or ISODD functions in Conditional Formatting Scott Paine Excel Worksheet Functions 6 December 6th 05 09:44 PM
enhanced conditional formatting Stuart Excel Discussion (Misc queries) 13 November 13th 05 07:20 PM
difficulty with conditional formatting Deb Excel Discussion (Misc queries) 0 March 23rd 05 06:13 PM


All times are GMT +1. The time now is 12:44 PM.

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

About Us

"It's about Microsoft Excel"