I have an autofill to the last row from A2 contingent on values being in Column D. Here is the code:
Range("A1").Select
ActiveCell.FormulaR1C1 = "#"
Range("A2").Select
ActiveCell.FormulaR1C1 = "1"
Range("A3").Select
Range("A3").Formula = "=IF(D3>0,A2+1,"""")"
Range("A3").Select
Selection.AutoFill Destination:=Range("A3:A" & Lastrow)
When I run this with only one row of data it changes A2 to =IF(D2>0,A1+1,"") because it is going up to the lastrow. Is there a formula anyone knows that will count sequentially as far or short as it is dragged down but remain a zero if there is no data.
Thanks
Range("A1").Select
ActiveCell.FormulaR1C1 = "#"
Range("A2").Select
ActiveCell.FormulaR1C1 = "1"
Range("A3").Select
Range("A3").Formula = "=IF(D3>0,A2+1,"""")"
Range("A3").Select
Selection.AutoFill Destination:=Range("A3:A" & Lastrow)
When I run this with only one row of data it changes A2 to =IF(D2>0,A1+1,"") because it is going up to the lastrow. Is there a formula anyone knows that will count sequentially as far or short as it is dragged down but remain a zero if there is no data.
Thanks