Forum Discussion

starr0650's avatar
starr0650
Copper Contributor
Aug 19, 2021
Solved

Count rows, end up will not work with only one row

I'm using the below code to find the last row, then autofill column A. 


LR = Cells(Rows.Count, 4).End(xlUp).Row
Range("A2").AutoFill Destination:=Range("A2:A" & LR)

 

It works unless there is only one value in column 4 (D2). If there are no values in D2 or if there is more than one value in column D (D2:D3... D2:D2000) the formula works. 

 

What do I need to do if there is only one value in column D (D2)?

Row A1:E1 are column heads.

 

Tank you for your help!

  • starr0650 

    For example:

        LR = Cells(Rows.Count, 4).End(xlUp).Row
        If LR <> 2 Then
            Range("A2").AutoFill Destination:=Range("A2:A" & LR)
        End If

Resources