mardi 31 juillet 2018

VBA IF formula not working?

I have some VBA code that is working between a few workbooks

I am running into a problem where I cannot get this IF formula to apply. I am not sure how I am getting Subscript out of range error.

I have tried to use .Range("O"), .Range("O:O"), .Range("O", i) but all give the same 1004 error.

Am I using .Range() wrong? I was able to use range on a different formula so not sure why this wont work.

Sub if_after()

    Dim co_detail As Workbook
    Set co_detail = ThisWorkbook

        With co_detail.Sheets("Detail")

            For i = 2 To 100
                .Range("02").Formula = "=IF(L" & i & "=N" & i & ",'good','update')"
            Next i

        End With

End Sub

Aucun commentaire:

Enregistrer un commentaire