Sub SortGridDataAndRefs()
'This code should be placed in a standard module in the workbook containing the data
'
'Sheet1 holds input table with the following characteristics:
' B1 as the first column header
' A2 as the first row header
' Data starting in B2 and going right and down,
' At least 1 blank row directly after the last row of data
' At least 1 blank column directly after the last column of data
' No fully blank rows within the data
' No fully blank columns within the data
'Sheet2 will be erased and the results will be placed there starting in cell A1.
ThisWorkbook.Activate
Dim rngCell As Range
Dim lngX As Long
With Sheets("Sheet2")
.Cells.Clear
lngX = 1
For Each rngCell In Intersect(Sheets("Sheet1").Range("B2").CurrentRegion.Offset(1, 1), Sheets("Sheet1").Range("B2").CurrentRegion)
.Cells(lngX, 1) = "Column " & rngCell.Column - 1
.Cells(lngX, 2) = "Row " & rngCell.Row - 1
.Cells(lngX, 3) = rngCell.Value
lngX = lngX + 1
Next
End With
Sheets("Sheet2").Select
Range("A1").CurrentRegion.Select
Selection.Sort Key1:=Range("C1"), Order1:=xlDescending, Header:=xlNo
Range("A1").Select
End Sub