View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Utkarsh Utkarsh is offline
external usenet poster
 
Posts: 18
Default rearranging data


Thanks tdw. This is what I came up with:

Sub re_organise()

Sheets("Sheet1").Select

i = 2
j = 2
Do While Cells(i, 1) < ""
If Cells(i, 1) < Cells(i + 1, 1) Then
Sheets("Sheet2").Cells(j, 1) = Cells(i - 1, 1).Value
Sheets("Sheet2").Cells(j, 2) = Cells(i - 1, 2).Value
Sheets("Sheet2").Cells(j, 3) = Cells(i - 1, 3).Value
Sheets("Sheet2").Cells(j, 4) = Cells(i, 2).Value
Sheets("Sheet2").Cells(j, 5) = Cells(i, 3).Value
End If
i = i + 1
j = j + 1
Loop

Sheets("Sheet2").Range("A:A").SpecialCells(xlCellT ypeBlanks).EntireRow.Delete


End Sub

I'm sure there are better and more elegant solutions especially since
I'm having to sort the data by ID and then by date for this to work.

Utkarsh