View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Wouter HM Wouter HM is offline
external usenet poster
 
Posts: 99
Default Reconstructing a table with Arrays

Hi Bythsx-Addagio,

In Excel 2007 I have crated this macro


Sub Adagio()
Dim lastRow As Long
Dim lastCol As Long
Dim loopRow As Long
Dim loopCol As Long
Dim outputRow As Long

lastRow = Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
lastCol = Cells(1, ActiveSheet.Columns.Count).End(xlToLeft).Column

outputRow = 1
For loopRow = 2 To lastRow
For loopCol = 2 To lastCol
If Not IsEmpty(ActiveSheet.Cells(loopRow, loopCol)) Then
outputRow = outputRow + 1
Sheets("Sheet2").Cells(outputRow, 1) =
ActiveSheet.Cells(loopRow, 1)
Sheets("Sheet2").Cells(outputRow, 2) = ActiveSheet.Cells(1,
loopCol)
Sheets("Sheet2").Cells(outputRow, 3) =
ActiveSheet.Cells(loopRow, loopCol)
End If
Next
Next

End Sub

HTH,

Wouter.