Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default format code not working properly

Hi,

I ran this code but when column G is less than 0, J is the only column that
dose not highlight the font red. I would appreciate any assistance.

Sub CondfmtLateEvents()
'Simulate conditional formatting
Dim rng1, rng2, cell As Range
Set rng1 = Range(Cells(1, 7), Cells(Rows.Count, 7).End(xlUp))
Set rng2 = Range(Cells(1, 10), Cells(Rows.Count, 10).End(xlUp))
'color entire row if column G is less than 0 and column H is null
For Each cell In rng1
If cell.Value < 0 And cell.Offset(0, 1) = "" Then
cell.EntireRow.Font.ColorIndex = 3
Else
cell.EntireRow.Font.ColorIndex = xlAutomatic
End If
Next
'color font in column J it is less than 0 and column H is null
For Each cell In rng2
If cell.Value < 0 And cell.Offset(0, -3) 0 And cell.Offset(0, -2) = ""
Then
cell.Font.ColorIndex = 3
Else
cell.Font.ColorIndex = xlAutomatic
End If
Next
End Sub

Thank you.
--
By persisting in your path, though you forfeit the little, you gain the
great.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default format code not working properly

Make sure you don't have conditional formating in column J. The conditional
formating will take precedence.

"DavidH56" wrote:

Hi,

I ran this code but when column G is less than 0, J is the only column that
dose not highlight the font red. I would appreciate any assistance.

Sub CondfmtLateEvents()
'Simulate conditional formatting
Dim rng1, rng2, cell As Range
Set rng1 = Range(Cells(1, 7), Cells(Rows.Count, 7).End(xlUp))
Set rng2 = Range(Cells(1, 10), Cells(Rows.Count, 10).End(xlUp))
'color entire row if column G is less than 0 and column H is null
For Each cell In rng1
If cell.Value < 0 And cell.Offset(0, 1) = "" Then
cell.EntireRow.Font.ColorIndex = 3
Else
cell.EntireRow.Font.ColorIndex = xlAutomatic
End If
Next
'color font in column J it is less than 0 and column H is null
For Each cell In rng2
If cell.Value < 0 And cell.Offset(0, -3) 0 And cell.Offset(0, -2) = ""
Then
cell.Font.ColorIndex = 3
Else
cell.Font.ColorIndex = xlAutomatic
End If
Next
End Sub

Thank you.
--
By persisting in your path, though you forfeit the little, you gain the
great.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default format code not working properly

Thank you Joel for your quick response. I don't have conditional formatting
but I have a formula. Maybe I need to hide the formula and just show
results. I don't know.
--
By persisting in your path, though you forfeit the little, you gain the
great.



"joel" wrote:

Make sure you don't have conditional formating in column J. The conditional
formating will take precedence.

"DavidH56" wrote:

Hi,

I ran this code but when column G is less than 0, J is the only column that
dose not highlight the font red. I would appreciate any assistance.

Sub CondfmtLateEvents()
'Simulate conditional formatting
Dim rng1, rng2, cell As Range
Set rng1 = Range(Cells(1, 7), Cells(Rows.Count, 7).End(xlUp))
Set rng2 = Range(Cells(1, 10), Cells(Rows.Count, 10).End(xlUp))
'color entire row if column G is less than 0 and column H is null
For Each cell In rng1
If cell.Value < 0 And cell.Offset(0, 1) = "" Then
cell.EntireRow.Font.ColorIndex = 3
Else
cell.EntireRow.Font.ColorIndex = xlAutomatic
End If
Next
'color font in column J it is less than 0 and column H is null
For Each cell In rng2
If cell.Value < 0 And cell.Offset(0, -3) 0 And cell.Offset(0, -2) = ""
Then
cell.Font.ColorIndex = 3
Else
cell.Font.ColorIndex = xlAutomatic
End If
Next
End Sub

Thank you.
--
By persisting in your path, though you forfeit the little, you gain the
great.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default format code not working properly

Check to see if there is event code under the sheet/tab. In the VBA, hit F8
to step through the code and see what happens on an incremental basis. You
should figure it out soon enough...

Good luck,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"DavidH56" wrote:

Thank you Joel for your quick response. I don't have conditional formatting
but I have a formula. Maybe I need to hide the formula and just show
results. I don't know.
--
By persisting in your path, though you forfeit the little, you gain the
great.



"joel" wrote:

Make sure you don't have conditional formating in column J. The conditional
formating will take precedence.

"DavidH56" wrote:

Hi,

I ran this code but when column G is less than 0, J is the only column that
dose not highlight the font red. I would appreciate any assistance.

Sub CondfmtLateEvents()
'Simulate conditional formatting
Dim rng1, rng2, cell As Range
Set rng1 = Range(Cells(1, 7), Cells(Rows.Count, 7).End(xlUp))
Set rng2 = Range(Cells(1, 10), Cells(Rows.Count, 10).End(xlUp))
'color entire row if column G is less than 0 and column H is null
For Each cell In rng1
If cell.Value < 0 And cell.Offset(0, 1) = "" Then
cell.EntireRow.Font.ColorIndex = 3
Else
cell.EntireRow.Font.ColorIndex = xlAutomatic
End If
Next
'color font in column J it is less than 0 and column H is null
For Each cell In rng2
If cell.Value < 0 And cell.Offset(0, -3) 0 And cell.Offset(0, -2) = ""
Then
cell.Font.ColorIndex = 3
Else
cell.Font.ColorIndex = xlAutomatic
End If
Next
End Sub

Thank you.
--
By persisting in your path, though you forfeit the little, you gain the
great.

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
format cells as zip code not working SS Excel Discussion (Misc queries) 3 December 3rd 09 02:53 AM
Please help VBA code not working properly send email when due dates Tia[_3_] Excel Worksheet Functions 0 July 21st 09 08:37 AM
Yes No box no working properly Miree Excel Programming 2 October 15th 08 08:14 AM
VBA Excel code not working properly (HELP!) zulfer7 Excel Discussion (Misc queries) 3 April 5th 07 10:49 PM
code not working properly - VBA beginner (random numbers generation, no repeats) msburza Excel Programming 4 May 11th 06 05:59 PM


All times are GMT +1. The time now is 04:53 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"