mardi 2 mai 2017

I want to insert a nested if statement, getting a Run time error 1004

I keep getting a run time error 1004 with the following code. Basically, I would like column d to have a Y label if column g is N, or N in column D if G is a Y, but if column g is blank, I want D to be blank as well. each time I run this, the amount of rows change.

Sub test()

Dim lastRow As Long
lastRow = Range("C" & Rows.Count).End(xlUp).Row
Range("D6").Formula = "=IF(G6=""Y"",""N"",IF(G6=""N"",""Y"",IF(G6="" "","" "")"
Range("D6").AutoFill Destination:=Range("D6:D" & lastRow)

Aucun commentaire:

Enregistrer un commentaire