Forum Discussion
starr0650
Aug 19, 2021Copper Contributor
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!
For example:
LR = Cells(Rows.Count, 4).End(xlUp).Row If LR <> 2 Then Range("A2").AutoFill Destination:=Range("A2:A" & LR) End If
2 Replies
Sort By