Option Explicit
Sub ReorgData()
With Excel.Application
.ScreenUpdating = False
.Calculation = Excel.xlManual
.EnableEvents = False
End With
' for Mat
'find active range
Sheets("M) Avg Hrs- Month").Select
Columns("A:A").Select
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Select
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(0, -1).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Copy
Dim a As Variant, b As Variant
Dim c As Long, i As Long, ii As Long
With Sheets("M) Avg Hrs- Month")
a = Selection
ReDim b(1 To (UBound(a, 1) * (UBound(a, 2) - 3)), 1 To 5)
End With
For c = 4 To UBound(a, 2)
For i = 2 To UBound(a, 1)
ii = ii + 1
b(ii, 1) = a(i, 1)
b(ii, 2) = a(i, 2)
b(ii, 3) = a(i, 3)
b(ii, 4) = a(1, c)
b(ii, 5) = a(i, c)
Next i
Next c
With Sheets("M) Data for PT")
.UsedRange.ClearContents
With .Cells(1, 1).Resize(, 5)
.Value = [{"Resource Name","Team","Department","Month","Hours"}]
.Font.Bold = True
End With
.Cells(2, 1).Resize(UBound(b, 1), UBound(b, 2)) = b
.Columns.AutoFit
.Activate
End With
'delete extra
Sheets("M) Data for PT").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Selection.Delete
Range("A1").Select
'Paste Values
Sheets("M) Data for PT").Select
Columns("E:E").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Columns("E:E").Select
Selection.NumberFormat = "0.0"
Range("A1").Select
ActiveWorkbook.Save
' for Arg
'find active range
Sheets("A) Avg Hrs- Month").Select
Columns("A:A").Select
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Select
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(0, -1).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Copy
Dim a As Variant, b As Variant
Dim c As Long, i As Long, ii As Long
With Sheets("M) Avg Hrs- Month")
a = Selection
ReDim b(1 To (UBound(a, 1) * (UBound(a, 2) - 3)), 1 To 5)
End With
For c = 4 To UBound(a, 2)
For i = 2 To UBound(a, 1)
ii = ii + 1
b(ii, 1) = a(i, 1)
b(ii, 2) = a(i, 2)
b(ii, 3) = a(i, 3)
b(ii, 4) = a(1, c)
b(ii, 5) = a(i, c)
Next i
Next c
With Sheets("A) Data for PT")
.UsedRange.ClearContents
With .Cells(1, 1).Resize(, 5)
.Value = [{"Resource Name","Team","Department","Month","Hours"}]
.Font.Bold = True
End With
.Cells(2, 1).Resize(UBound(b, 1), UBound(b, 2)) = b
.Columns.AutoFit
.Activate
End With
'delete extra
Sheets("A) Data for PT").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Selection.Delete
Range("A1").Select
'Paste Values
Sheets("A) Data for PT").Select
Columns("E:E").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Columns("E:E").Select
Selection.NumberFormat = "0.0"
Range("A1").Select
ActiveWorkbook.Save
' for Nap
'find active range
Sheets("N) Avg Hrs- Month").Select
Columns("A:A").Select
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
ActiveCell.Offset(-1, 0).Select
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(0, -1).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Copy
Dim a As Variant, b As Variant
Dim c As Long, i As Long, ii As Long
With Sheets("N) Avg Hrs- Month")
a = Selection
ReDim b(1 To (UBound(a, 1) * (UBound(a, 2) - 3)), 1 To 5)
End With
For c = 4 To UBound(a, 2)
For i = 2 To UBound(a, 1)
ii = ii + 1
b(ii, 1) = a(i, 1)
b(ii, 2) = a(i, 2)
b(ii, 3) = a(i, 3)
b(ii, 4) = a(1, c)
b(ii, 5) = a(i, c)
Next i
Next c
With Sheets("N) Data for PT")
.UsedRange.ClearContents
With .Cells(1, 1).Resize(, 5)
.Value = [{"Resource Name","Team","Department","Month","Hours"}]
.Font.Bold = True
End With
.Cells(2, 1).Resize(UBound(b, 1), UBound(b, 2)) = b
.Columns.AutoFit
.Activate
End With
'delete extra
Sheets("N) Data for PT").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Selection.Delete
Range("A1").Select
'Paste Values
Sheets("N) Data for PT").Select
Columns("E:E").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Columns("E:E").Select
Selection.NumberFormat = "0.0"
Range("A1").Select
ActiveWorkbook.Save
With Excel.Application
.ScreenUpdating = True
.Calculation = Excel.xlAutomatic
.EnableEvents = True
End With
End Sub
Bookmarks