This is what I am trying to do. I have a data where the first column is the serial number and that row is its data. The serial number can be in multiple rows. I want to find each instance, capture two pieces of data (a date and value), and put it all on one row in another sheet. For example
a, 1/9/11, 1
a, 1/17/11, 2
a, 1/28/11, 3
becomes
a, 1/9/11, 1, 1/17/11, 2, 1/28/11, 3
(commas denote next cell)
My code so far:
a = Application.WorksheetFunction.CountA(Columns(1))
i = 2
s = 2
linea: 'reit point
Sheets("Sheet1").Select
For x = i To 25
c = 1
If Cells(x + 1, 1) <> Cells(x, 1) Then GoTo line1
c = c + 1
s = x
Next x
line1: 'Jump out
MsgBox (c)
sn = Cells(x, 1)
ReDim d(c) As Date
ReDim v(c) As Long
g = 0
For y = (x - c) + 1 To s + 1
g = g + 1
d(g) = Cells(y, 8)
v(g) = Cells(y, 21)
Next y
Sheets("Sheet3").Select
b = Application.WorksheetFunction.CountA(Columns(1)) + 1
Cells(b, 1) = sn
g = 0
For y = 2 To c * 2 Step 2
g = g + 1
Cells(b, y) = d(g)
Cells(b, y + 1) = v(g)
Next y
i = i + c
c = 0
If i < 25 Then GoTo linea
But the results are the last of the duplicates repeated for the number of times the serial number shows up. Can anyone see the error?
a, 1/9/11, 1
a, 1/17/11, 2
a, 1/28/11, 3
becomes
a, 1/9/11, 1, 1/17/11, 2, 1/28/11, 3
(commas denote next cell)
My code so far:
a = Application.WorksheetFunction.CountA(Columns(1))
i = 2
s = 2
linea: 'reit point
Sheets("Sheet1").Select
For x = i To 25
c = 1
If Cells(x + 1, 1) <> Cells(x, 1) Then GoTo line1
c = c + 1
s = x
Next x
line1: 'Jump out
MsgBox (c)
sn = Cells(x, 1)
ReDim d(c) As Date
ReDim v(c) As Long
g = 0
For y = (x - c) + 1 To s + 1
g = g + 1
d(g) = Cells(y, 8)
v(g) = Cells(y, 21)
Next y
Sheets("Sheet3").Select
b = Application.WorksheetFunction.CountA(Columns(1)) + 1
Cells(b, 1) = sn
g = 0
For y = 2 To c * 2 Step 2
g = g + 1
Cells(b, y) = d(g)
Cells(b, y + 1) = v(g)
Next y
i = i + c
c = 0
If i < 25 Then GoTo linea
But the results are the last of the duplicates repeated for the number of times the serial number shows up. Can anyone see the error?