#1   Report Post  
kevcar40
 
Posts: n/a
Default dates

hi
i have the following code that checks two date (A1 and B1) values this
returns the number of days in C1
if the number is bigger than 2 and the word Complete has not been
enter in D1 the cell is coloured Red

How can i adapt the code so i can enter numerous values in column A and
b and return the values in column C colouring the appropriate cell in
Coloum D ?


Sub test_date()
If ThisWorkbook.Worksheets("sheet1").Range("D1").Valu e < "Complete"
And ThisWorkbook.Worksheets("sheet1").Range("C1").Valu e 2 Then
ThisWorkbook.Worksheets("sheet1").Range("D1").Sele ct
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
End Sub

  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way:

Public Sub test_date2()
Dim rCell As Range
With ThisWorkbook.Sheets("sheet1").Range("D1:D" & _
Range("D" & Rows.Count).End(xlUp).Row)
.Interior.ColorIndex = xlColorIndexAutomatic
For Each rCell In .Cells
With rCell
If .Value < "Complete" Then
If .Offset(0, -1).Value 2 Then
With .Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
End If
End With
Next rCell
End With
End Sub



In article om,
"kevcar40" wrote:

hi
i have the following code that checks two date (A1 and B1) values this
returns the number of days in C1
if the number is bigger than 2 and the word Complete has not been
enter in D1 the cell is coloured Red

How can i adapt the code so i can enter numerous values in column A and
b and return the values in column C colouring the appropriate cell in
Coloum D ?


Sub test_date()
If ThisWorkbook.Worksheets("sheet1").Range("D1").Valu e < "Complete"
And ThisWorkbook.Worksheets("sheet1").Range("C1").Valu e 2 Then
ThisWorkbook.Worksheets("sheet1").Range("D1").Sele ct
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
End Sub

  #3   Report Post  
kevcar40
 
Posts: n/a
Default

thanks for reply
i have tried this code and found that it only fills the cell D1
if i have another value bigger than 2 in row 3 or 4 etc it does not
colour the cell
any idea how i can get it to read the columns in C an D and colour if
necessary

thaks again

kevin

  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

If you have nothing already in the cells in column D, change the "D1:D"
and "D" to "C1:C" and "C", respectively. That will run the code on every
row for which there's a value in column C.

In article . com,
"kevcar40" wrote:

i have tried this code and found that it only fills the cell D1
if i have another value bigger than 2 in row 3 or 4 etc it does not
colour the cell
any idea how i can get it to read the columns in C an D and colour if
necessary

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
Default Dates Sue Excel Discussion (Misc queries) 1 July 22nd 05 12:29 PM
Using dates for x-axis values as string instead of creating a scale cs_weirdo Charts and Charting in Excel 2 June 17th 05 12:20 AM
Stop Excel Rounding Dates leinad512 Excel Discussion (Misc queries) 1 April 20th 05 04:19 PM
Formating Dates for production schedule dpl7579 Excel Discussion (Misc queries) 1 January 11th 05 08:43 PM
due dates Niki New Users to Excel 4 January 10th 05 04:11 PM


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