title: Excel macro for series autofill
body: <p>I would like to ask how to create macro to autofill serial/series(1, 2, 3 and so on) from row A2 up to the end of data where there is data from Column B?</p>
  
  <p>I use this code:</p>
  
  <pre><code>  Sub FillHandle()
    If IsEmpty(ActiveCell.Value) Then Exit Sub
    If ActiveCell.Row = Rows.Count Then Exit Sub
    If ActiveCell.Column &gt; 1 Then
      If Not IsEmpty(ActiveCell.Offset(, -1)) And Not IsEmpty(ActiveCell.Offset(1, -1)) Then
        Range(ActiveCell, ActiveCell.Offset(, -1).End(xlDown).Offset(, 1)).FillDown
        Exit Sub
      End If
    End If
    If ActiveCell.Column &lt; Columns.Count Then
      If Not IsEmpty(ActiveCell.Offset(, 1)) And Not IsEmpty(ActiveCell.Offset(1, 1)) Then
        Range(ActiveCell, ActiveCell.Offset(, 1).End(xlDown).Offset(, -1)).FillDown
        Exit Sub
      End If
    End If
  End Sub
  </code></pre>
  
  <p>However, it just autofill "1" all through out.</p>
  
  <p>Below is the format of my excel sheet.</p>
  
  <p><a href="https://i.stack.imgur.com/b6peB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b6peB.png" alt="enter image description here"></a></p>
  
  <p>Thank you in advance!</p>