Re: Update cell based on value in another cell
Hi josh
Have a look and see if this will work.
I changed the formulas down column "I" to do away with all those days over due in the yet to be used rows.
=IF(OR(ISBLANK(F11),ISBLANK(G11),ISBLANK(H11)),"",IF(TODAY()>H11,TODAY()-H11,""))
Because column I is formulas, need to use the Worksheet_Calculate event.
I've used column Z to hold a formula in Z7
=SUMPRODUCT(--(I9:I219<>Z9:Z219))
and a copy of I9:I219 in Z9:Z219.
If this location is a problem it could be made to use a separate sheet if need be.
If Z7 is 0, the two ranges match so it wasn't an I column calculation that triggered the event.
If Z7 isn't zero some value in column I is different so the macro proceeds.
Private Sub Worksheet_Calculate()
If [Z7] = 0 Then Exit Sub
Dim CurCel As String
Dim cel As Range
On Error GoTo CleanExit:
'for relocating cursor after the copy
CurCel = Replace(ActiveCell.Address, "$", "")
Application.ScreenUpdating = False
Application.EnableEvents = False
Range("I9:I219").Copy
Range("Z9:Z219").PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
For Each cel In Range("I9:I219")
If cel.Value <> "" Then
cel.Offset(0, 3).Value = "Overdue"
End If
Next cel
Range(CurCel).Activate
Application.ScreenUpdating = True
Application.EnableEvents = True
Exit Sub
CleanExit:
Application.ScreenUpdating = True
Application.EnableEvents = True
Err.Clear
End Sub
Display More
Is changing L11 to 'Complete' (or anything else) after being automatically changed to 'Overdue' something you would normally do?
If so we'll need to address that too.