View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Re-organize data in Excel - I need help

Public Sub ProcessData()
Dim i As Long, j As Long
Dim iLastRow As Long
Dim iLastCol As Long
Dim sCheck As String

With ActiveSheet

Application.ScreenUpdating = False

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow - 1

sCheck = .Cells(i, "A").Value
For j = i + 1 To iLastRow

If .Cells(j, "A") < sCheck Then
Exit For
End If
iLastCol = .Cells(j, .Columns.Count).End(xlToLeft).Column
If iLastCol 1 And _
.Cells(i, iLastCol).Value = "" Then

.Cells(i, iLastCol).Value = .Cells(j, iLastCol).Value
.Cells(j, iLastCol).Value = ""
End If
Next j
Next i


For i = iLastRow To 1 Step -1
If Application.CountA(.Cells(i, "B").Resize(, 3)) = 0 Then
.Rows(i).Delete
End If
Next i

Application.ScreenUpdating = True
End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"ina" wrote in message
ups.com...
Hello,

I have a problem with Excel VBA. I would like to transform figure A in
Figure B

Figure A
A B C D
1 AA ABC
2 AA AC
3 AA DD
4 AA CD
5 AA CD
6 BB BBC
7 BB CC
8 BB BBC
9 BB CD
10 BB DE


Figure B
A B C D
1 AA ABC AC DD
2 AA CD
3 AA CD
4 BB BBC BBC DE
5 BB CC CD



I tried in several ways but still I did not get the figure B result.
Could someone help me on that issue?

regards,
Ina