Option Explicit
Sub ReorgDataV2()
' stanleydgromjr, 01/21/2014, EF983186
Dim lr As Long, sr As Long, rng As Range
Dim prng As Range, nrng As Range, grng As Range, irng As Range
Dim p As Variant, n As Variant, g As Variant, i As Variant
Application.ScreenUpdating = True
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("A2:D" & lr)
Set prng = rng.Find("Player", LookAt:=xlWhole)
Set nrng = rng.Find("Number", LookAt:=xlWhole)
Set grng = rng.Find("GPA", LookAt:=xlWhole)
Set irng = rng.Find("IQ Score", LookAt:=xlWhole)
If (Not prng Is Nothing) * (Not nrng Is Nothing) * (Not grng Is Nothing) * (Not irng Is Nothing) Then
sr = prng.Row + 1
p = Range(Cells(sr, prng.Column), Cells(lr, prng.Column))
n = Range(Cells(sr, nrng.Column), Cells(lr, nrng.Column))
g = Range(Cells(sr, grng.Column), Cells(lr, grng.Column))
i = Range(Cells(sr, irng.Column), Cells(lr, irng.Column))
Range("A" & sr - 1 & ":D" & lr).ClearContents
Range("A" & sr).Resize(UBound(p, 1), UBound(p, 2)) = p
Range("B" & sr).Resize(UBound(n, 1), UBound(n, 2)) = n
Range("C" & sr).Resize(UBound(g, 1), UBound(g, 2)) = g
Range("D" & sr).Resize(UBound(i, 1), UBound(i, 2)) = i
lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2:D" & lr).Sort key1:=Range("A2"), order1:=1
ElseIf (prng Is Nothing) * (nrng Is Nothing) * (grng Is Nothing) * (irng Is Nothing) Then
Application.ScreenUpdating = True
MsgBox "One or more of the titles 'Player' 'Number' 'GPA' 'IQ Score' were NOT found after row 1 - macro terminated!"
Exit Sub
End If
Application.ScreenUpdating = True
End Sub
Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension
Bookmarks