【发布时间】:2014-12-11 20:15:30
【问题描述】:
我的记录从 B8 单元格开始,我需要在 A 列中对它们进行计数,从单元格 A8 开始。
我使用了这个问题“autofill down according to adjacent column”的答案,但是当记录计数为 0 或 1 时我该如何处理?当有 1 条记录时,它会出错。似乎自动填充无法自动填充一个单元格。
我有一些条件测试零和一,但有没有更简洁的方法呢?
LastRow = Cells(Rows.Count, 2).End(xlUp).Row 'Find last row
If LastRow >= 8 Then 'If recordcount is 1 or greater
Range("A8").FormulaR1C1 = "1" 'First number is "1"
If Not LastRow = 8 Then 'If not recordcount exactly 1
'Enumerate the remaining records with Autofill
Range("A8").AutoFill Destination:=Range("A8:A" & LastRow), Type:=xlLinearTrend
End If
End If
【问题讨论】: