Ok - I admit - I am adding two questions into one thread.
First scenario:
In column G - I have different phases. I need to calucate how many dates it's been in that phase. It's an easy formula =networkdays(O2,Today(), Holidays A1:A10). O2 is the day that it moved into that phase.
Here's the problem. There are 7 phases. And 7 different date columns based on the phase and when it moved into that phase. So for the 1st phase you use O, 2nd phase you use P, 3rd phase you use Q, etc to figure out the correct date of the phase. I didn't want to do a nested if function because they get messy and don't translate well to VBA. I decided to create a function and build a case statement. I am having issues in the code making it work with a formula as the case result. I have been able to use this for other items and it has worked well, but I can't figure out how to get this formula to work within the case statement.
I could really use some help!
Second scenario:
This one is around conditional formatting. But I want the code for it in <acronym>VBA</acronym> rather than using the conditional formatting box. And if feels like it could be handled with similar code as with a case statement.
I have two cells that I would like the color the first cell based on the conditions of both cells.
Example:
If A1= "Phase 1", B1= "Incomplete" then color A1 green
else
A1= "Phase 2", B1= "Incomplete" then color A1 yellow
else
A1= "Phase 3", B1= "Incomplete" then color A1 red
else
A1= "Phase 3", B1= "Complete" then color A1 Blue
Or second Example:
If A1= "Phase 1", B1= (>=-20) then color A1 green
else
A1= "Phase 2", B1= (-6 To -19) then color A1 yellow
else
A1= "Phase 3", B1= (<=5) then color A1 red
Please help!!

First scenario:
In column G - I have different phases. I need to calucate how many dates it's been in that phase. It's an easy formula =networkdays(O2,Today(), Holidays A1:A10). O2 is the day that it moved into that phase.
Here's the problem. There are 7 phases. And 7 different date columns based on the phase and when it moved into that phase. So for the 1st phase you use O, 2nd phase you use P, 3rd phase you use Q, etc to figure out the correct date of the phase. I didn't want to do a nested if function because they get messy and don't translate well to VBA. I decided to create a function and build a case statement. I am having issues in the code making it work with a formula as the case result. I have been able to use this for other items and it has worked well, but I can't figure out how to get this formula to work within the case statement.
Code:
Function CurrentDaysStatus(G As Range, O As Range, P As Range, Q As Range, R As Range, S As Range, T As Range, U As Range)
Dim sCurrentDays As String
Select Case G.Value
Case "Intent"
' Days determined by column 0
Select Case O.Value
Case ActiveCell.FormulaR1C1 = sCurrentDays = "=NETWORKDAYS(LC[-7],TODAY(),holidays!R1C2:R10C2)"
Case "AE Review"
' Days determined by column P
Select Case P.Value
Case ActiveCell.FormulaR1C1 = sCurrentDays = "=NETWORKDAYS(LC[-8],TODAY(),holidays!R1C2:R10C2)"
Case "Submitted for IRR"
' Days determined by column Q
Select Case Q.Value
Case ActiveCell.FormulaR1C1 = sCurrentDays = "=NETWORKDAYS(LC[-9],TODAY(),holidays!R1C2:R10C2)"
Case "RIA Review"
' Days determined by column R
Select Case R.Value
Case ActiveCell.FormulaR1C1 = sCurrentDays = "=NETWORKDAYS(LC[-10],TODAY(),holidays!R1C2:R10C2)"
Case "AE Delivery Decision"
' Days determined by column S
Select Case S.Value
Case ActiveCell.FormulaR1C1 = sCurrentDays = "=NETWORKDAYS(LC[-11],TODAY(),holidays!R1C2:R10C2)"
Case "Delivery"
' Days determined by column T
Select Case T.Value
Case ActiveCell.FormulaR1C1 = sCurrentDays = "=NETWORKDAYS(LC[-12],TODAY(),holidays!R1C2:R10C2)"
Case "Launch /Look Back"
' Days determined by column U
Select Case U.Value
Case ActiveCell.FormulaR1C1 = sCurrentDays = "=NETWORKDAYS(LC[-9],TODAY(),holidays!R1C2:R10C2)"
Case Else
' for anything not covered above
sCurrentDays = "Review Date"
End Select
CurrentDaysStatus = sCurrentDays
End Function
Second scenario:
This one is around conditional formatting. But I want the code for it in <acronym>VBA</acronym> rather than using the conditional formatting box. And if feels like it could be handled with similar code as with a case statement.
I have two cells that I would like the color the first cell based on the conditions of both cells.
Example:
If A1= "Phase 1", B1= "Incomplete" then color A1 green
else
A1= "Phase 2", B1= "Incomplete" then color A1 yellow
else
A1= "Phase 3", B1= "Incomplete" then color A1 red
else
A1= "Phase 3", B1= "Complete" then color A1 Blue
Or second Example:
If A1= "Phase 1", B1= (>=-20) then color A1 green
else
A1= "Phase 2", B1= (-6 To -19) then color A1 yellow
else
A1= "Phase 3", B1= (<=5) then color A1 red
Please help!!
