conditional formating across worksheets

ErinJ

New Member
Joined
May 27, 2011
Messages
26
I am creating a gantt chart
I have two sheets:
Projects
Schedules
In Projects I have 2 columns
Start Date
Completion Date
In Schedules I have the same projects mirrored but I have a column for each day of the month/year. I have put the corresponding date in each cell and formated white so no one can see it.
I want the corresponding Job to change the color of the cell to blue if it falls within the cell range of Start Date and Completion Date in Projects.
Here is a sample of code I'm playing with but it doesn't work. I'm probably on the wrong track.

HTML:
Select Case Range("C6:C371").Value
        Case Is => "PROJECTS!E5" < "PROJECTS!E6"
            Range("C6:C371").FormatConditions(1).Interior.ColorIndex=5
          Case Else
                Range("C6C371").FormatConditions(1).Interior.ColorIndex= White?
    End Select
 
VOG - I feel like an idiot!
I was ref the wrong cell Projects was not E5 & E6 but E5 and F5. Hours wasted for lack of paying attention to details. (I shall flog myself 7 times) Now maybe I can try your original suggestion and it work better. I do apologize.
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
HTML:
For i = 6 To 371
    With Range("C" & i)
        If .Value >= Sheets("PROJECTS").Range("E5").Value And .Value < Sheets("PROJECTS").Range("F5").Value Then
            .Interior.ColorIndex = 5
          Else
            .Interior.ColorIndex = 2
        End If
    End With
Next i

Ok so I made that small change and it still doesn't work. I also just realized there are only 256 columns in excel and I need 366 for this to work. (365 days plus 1 for job titles) Any thoughts?
 
Upvote 0
Date comparison can be a bit iffy in VBA. Maybe

Code:
For i = 6 To 371
    With Range("C" & i)
        If CLng(.Value) >= CLng(Sheets("PROJECTS").Range("E5").Value) And CLng(.Value) < CLng(Sheets("PROJECTS").Range("F5").Value) Then
            .Interior.ColorIndex = 5
          Else
            .Interior.ColorIndex = 2
        End If
    End With
Next i

Re the 256 column limitation, you would need to reconfigure your project to use rows instead of columns for the dates or upgrade to Excel 2007 or later.
 
Upvote 0
Using Excel 2007 and after I got all the lines added I got a compile error procedure to large.

Any thoughts?
 
Upvote 0
If you save the file in .xlsm format, close it then reopen it you should find that you have a lot more than 256 columns.

As far as I know the maximum size of a compiled procedure is 44K which is pretty massive.
 
Upvote 0

Forum statistics

Threads
1,215,537
Messages
6,125,393
Members
449,222
Latest member
taner zz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top