Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Format Row on Condition in Cell

Hi.

Hope someone can help me;

I have written the following code using the Macro recorder and edite
it a bit and it does half of what i want it to do. It finds any cell i
the range that contains a '0' and then turns it red.

But what i need it to do is if it finds a '0' in the range BU4:BW4 o
below it needs to turn the row that cell is in to red font from BT:CC.

I don't know if the above makes sense. So heres an e.g.

In BU7 there is a '0' so then it turns from BT7 to CC7 into red font.

Here's what i have so far.

For Each sh In Worksheets
sh.Activate
Range("BU4:BW4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue
Operator:=xlEqual, _
Formula1:="0"
Selection.FormatConditions(1).Font.ColorIndex = 3
Nex

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Format Row on Condition in Cell

Try this-

Sub MakeFontRed()

Dim num As Integer
num = 4

For Each sh In Worksheets
sh.Activate
Do
If Range("BU" & num).Value = 0 Or Range("BV" & num).Value = 0 O
Range("BW" & num).Value = 0 Then
Range("BU" & num).EntireRow.Font.ColorIndex = 3
End If
num = num + 1

Loop Until Range("BU" & num).Value = ""
Next

End Sub



-Gitcyphe

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Format Row on Condition in Cell

That works a charm. Thank you.

Just one quick question. I can just about understand what is happenin
in the code - but the last line after the 'end if'

num=num+1 i don't understand whats happening here, i'd be ver
grateful if you could explain.

Thanks again

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Format Row on Condition in Cell

The num = num + 1 is a counter. I set the value of num to be '4
initially, because you started at BU4. Every time code completed on
loop, it would add 1 to 'num'. Increasing num meant increasing the ro
number to work with.

-Gitcyphe

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Format Row on Condition in Cell

Cheers, it makes sense to me now.

Thanks again

--
Message posted from http://www.ExcelForum.com

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
If function using cell format as the condition Janie Excel Worksheet Functions 3 December 9th 09 07:20 AM
Condition Format with 2 cell Kim Excel Worksheet Functions 5 February 27th 09 11:07 AM
Cell format as condition mars Excel Worksheet Functions 1 November 24th 08 02:17 AM
How do i change the format of a cell based on the condition of another cell in same row? scott23 Excel Programming 1 January 6th 04 03:03 PM


All times are GMT +1. The time now is 06:03 AM.

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"