I have the following table
Item Descr Date Qty/Rate
a aaa 7/24/2018 504
a aaa 9/18/2018 504
a aaa 11/2/2018 504
b bbb 7/31/2018 756
b bbb 8/15/2018 168
b bbb 9/21/2018 756
b bbb 10/19/2018 756
b bbb 11/16/2018 756
b bbb 12/14/2018 756
b bbb 2/8/2019 756
c ccc 9/4/2018 100
d d 10/5/2018 200
e e 8/6/2018 12
I have the following code. I want to concatenate dates and amounts in a string per item. However I keep skipping or missing the first date. If there's only one entry it misses that item all together. Why am I missing the first entry?
Item Descr Date Qty/Rate
a aaa 7/24/2018 504
a aaa 9/18/2018 504
a aaa 11/2/2018 504
b bbb 7/31/2018 756
b bbb 8/15/2018 168
b bbb 9/21/2018 756
b bbb 10/19/2018 756
b bbb 11/16/2018 756
b bbb 12/14/2018 756
b bbb 2/8/2019 756
c ccc 9/4/2018 100
d d 10/5/2018 200
e e 8/6/2018 12
I have the following code. I want to concatenate dates and amounts in a string per item. However I keep skipping or missing the first date. If there's only one entry it misses that item all together. Why am I missing the first entry?
Code:
Sub Button1_Click()
Dim CurItem As String
Dim PromDate As String
Dim NumRows As Integer
Dim X As Integer
Range("A2").Select
NumRows = Range("A2", Range("A2").End(xlDown)).Rows.Count
CurItem = ActiveCell.Value
'PromDate = PromDate & ActiveCell.Offset(0, 2).Value & "," & ActiveCell.Offset(0, 3).Value
For X = 1 To NumRows
' ActiveCell.Offset(1, 0).Select
If ActiveCell.Value = CurItem Then
PromDate = PromDate & ", " & ActiveCell.Offset(0, 2).Value & ", " & ActiveCell.Offset(0, 3).Value
ElseIf ActiveCell.Value <> curritem Then
If Len(PromDate) > 0 Then
PromDate = Right(PromDate, Len(PromDate) - 2)
End If
ActiveCell.Offset(-1, 4).Value = PromDate
PromDate = ""
'CurItem = ActiveCell.Offset(-1, 0).Value
End If
ActiveCell.Offset(-1, 0).Select
Next X
MsgBox "done"
End Sub
[code]