Please kindly follow this analogy.
I have a spreadsheet that I want to populate with values from my code. The values should be in this way:
Example is this:

cell1 cell2
1 1
1 2
1 3
1 4
2 1
2 2
3 1
3 2
3 3
3 4
3 5
this is just a sample code. as we can see, cell1 is a parent to cell2. as long as the value in cell1 does not change cell2 will continue to increment,
when the value of cell1 changes, cell2 will start counting from 1 again.

If Trim(lRow < 4) Then
'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.txtTransaction.Value
.Cells(lRow, 2).Value = 1
.Cells(lRow, 3).Value = Me.ComboBoxAccount.Value
.Cells(lRow, 7).Value = Me.txtAmount.Value
End With
End If

Dim str As Integer
str = ws.Cells(lRow - 1, 2).Value

If Trim(lRow > 3 & ws.Cells(lRow, 1).Value = str) Then
With ws
.Cells(lRow, 1).Value = Me.txtTransaction.Value
.Cells(lRow, 2).Value = .Cells(lRow - 1, 2).Value + 1
.Cells(lRow, 3).Value = Me.ComboBoxAccount.Value
.Cells(lRow, 7).Value = Me.txtAmount.Value
Exit Sub
End With
End If

I have this code i have been trying out but not giving me the result. Pls. how do I achieve this. Thanks God bless in Jesus name.