Try this
![]()
Option Explicit Sub Autonumber() Dim ws As Worksheet Dim LastRow As Long For Each ws In ThisWorkbook.Worksheets With ws LastRow = .Range("J65536").End(xlUp).Row .Range("A2").Formula = "=if(J2>0,row(A1),"""")" .Range("A2").AutoFill Destination:=.Range("A2:A" & LastRow), Type:=xlFillDefault .Range("A2", .Range("A2").End(xlDown)).Copy .Range("A2", .Range("A2").End(xlDown)).PasteSpecial (xlPasteValues) End With Next ws End Sub
Bookmarks