vendredi 22 mai 2015

If statements in a macro not updating fields correctly

I've racked my brain with this one all day but it simply doesn't make sense to me. I'm using the following code:

Dim statdate As Long
    statdate = ActiveSheet.Range("F" & Rows.Count).End(xlUp).Row

Range("O2").Select
Range("O2").FormulaR1C1 = "=IF(RC[-9]<TODAY(),""Booked"",""Provisional Booking"")"
Range("O2").Copy Destination:=Range("O3:O" & statdate)

Dim canc As Long
    canc = ActiveSheet.Range("AH" & Rows.Count).End(xlUp).Row

Range("AI2").FormulaR1C1 = "=IF(RC[-1]=""Yes"",""Cancelled"",""Booked"")"
Range("AI2").Copy Destination:=Range("AI3:AI" & canc)

It should work out two statuses for two different fields - but it returns only "Booked" in column "O" and "Booked" in column "AH". This would be fine and usually I would search for an error but when I go back to the spreadsheet and highlight any of the cells in column "O" that should be "Provisional Booking" or cells in column "AH" that should be "Cancelled" to check individual formulas it changes to the correct outcome after I highlight the cell in "AH" and "F" respectively.

Basically, the formula is right but it wont change until I manually check each cell.

Can you guys think of why this might be. I'd really appreciate any help on this one.

Thank you in advance

Aucun commentaire:

Enregistrer un commentaire