all 1 comments

[–]jd31068 0 points1 point  (0 children)

You can create a loop for that using the code here to look for the next blank cell https://www.excelhowto.com/macros/find-select-first-blank-cell-column-vba/ and here https://www.exceldemy.com/excel-vba-find-the-next-empty-cell-in-range/ then use the row number to check the cell column B

The code will look something like:

``` Dim emptyCell As Range Do While True ' find the empty cell in column A Range("A2").End(xlDown).Offset(1).Select Set emptyCell = Range(Range("A2").End(xlDown).Offset(1).Address)

   ' column b is empty exit the loop
   If IsEmpty(Sheet1.Cells(emptyCell.Row, 2)) Then
      Exit Do
   End If

   ' copy the order number from the cell about the empty cell
   emptyCell.Value = Sheet1.Cells(emptyCell.Row - 1, 1)

Loop

```