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.
|