Reputation: 3
I just want to produce a same code for all the blank cells follow the non-blank above cell.
Upvotes: 0
Views: 182
Reputation: 14580
Assuming the first row of your table is populated with a value you can drop this into the 2nd row (D4
in your photo) and drag down as needed
=IF(B4="",A3,A3+1)
If you did decide to go with VBA you could try this macro. Note this does not need the first row of table to be populated and the numbering will stop at the last value found in the Type
column
Sub Test()
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")
Dim xCell As Range
For Each xCell In ws.Range("A3:A" & ws.Range("B" & ws.Rows.Count).End(xlUp).Row)
If xCell.Offset(0, 1) <> "" Then
xCell = Application.WorksheetFunction.Max(ws.Range("A3:A" & xCell.Row)) + 1
Else
xCell = xCell.Offset(-1)
End If
Next xCell
End Sub
Upvotes: 1
Reputation: 3563
Welcome to SO,
You can try using a simple COUNTIF
approach:
=COUNTIF($B$3:B3,"<>"&"")
This will count how many Solo/Convoys are not blank in a given range. For column E, use =B3&""
to copy the values from column B.
Upvotes: 0