Sub Parth007yy()
Dim i As Long, t As Long
Dim j As String, m As String, o As String, p As String, q As String
Dim rcell As Range, u As Range, v As Range, w As Range, z As Range, z1 As Range, z2 As Range, z3 As Range, z4 As Range, z5 As Range
Dim wsIn As Worksheet, wsOut As Worksheet
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Set wsIn = Sheets("Input")
Set wsOut = Sheets("Output")
On Error Resume Next
wsOut.Range("B13:B" & Range("A" & Rows.Count).End(9).Row).SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Delete
On Error GoTo 0
With wsIn
t = wsOut.Range("A" & Rows.Count).End(3).Row
For i = .Range("C" & Rows.Count).End(3).Row To 2 Step -1
Select Case .Cells(i, "C")
Case Is = 1
Set u = wsOut.Columns(1).Find("1 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not u Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(u.Row, "A").Offset(1).EntireRow.Insert
End If
Set u = Nothing
Case Is = 2
Set v = wsOut.Columns(1).Find("2 MegaByte", LookIn:=xlValues, lookat:=xlPart)
If Not v Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(v.Row, "A").Offset(1).EntireRow.Insert
End If
Set v = Nothing
Case Is = 3
Set w = wsOut.Columns(1).Find("3 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not w Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(w.Row, "A").Offset(1).EntireRow.Insert
End If
Set w = Nothing
Case Is = 4
Set z = wsOut.Columns(1).Find("4 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not z Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(z.Row, "A").Offset(1).EntireRow.Insert
End If
Set z = Nothing
Case Is = 5
Set z1 = wsOut.Columns(1).Find("5 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not z1 Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(z1.Row, "A").Offset(1).EntireRow.Insert
End If
Set z1 = Nothing
Case Is = 6
Set z2 = wsOut.Columns(1).Find("6 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not z2 Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(z2.Row, "A").Offset(1).EntireRow.Insert
End If
Set z2 = Nothing
Case Is = 7
Set z3 = wsOut.Columns(1).Find("7 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not z3 Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(z3.Row, "A").Offset(1).EntireRow.Insert
End If
Set z3 = Nothing
Case Is = 8
Set z4 = wsOut.Columns(1).Find("8 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not z4 Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(z4.Row, "A").Offset(1).EntireRow.Insert
End If
Set z4 = Nothing
Case Is = 9
Set z5 = wsOut.Columns(1).Find("9 TeraByte", LookIn:=xlValues, lookat:=xlPart)
If Not z5 Is Nothing Then
.Range(.Cells(i, "E"), .Cells(i, "U")).Copy
wsOut.Cells(z5.Row, "A").Offset(1).EntireRow.Insert
End If
Set z5 = Nothing
End Select
Next i
End With
t = wsOut.Range("A" & Rows.Count).End(3).Row
With wsOut
For Each numrange In .Columns(10).SpecialCells(xlConstants, xlNumbers).Areas
sumaddr = numrange.Address(False, False)
numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
c = numrange.Count
Next numrange
For Each numrange In .Columns(13).SpecialCells(xlConstants, xlNumbers).Areas
sumaddr = numrange.Address(False, False)
numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
c = numrange.Count
Next numrange
For i = 15 To 17
For Each numrange In .Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
sumaddr = numrange.Address(False, False)
numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
c = numrange.Count
Next numrange
Next i
nodata:
On Error Resume Next
.Range(.Cells(13, 1), .Cells(t, 1)).SpecialCells(4).EntireRow.Delete
On Error GoTo 0
j = ""
m = ""
o = ""
p = ""
q = ""
For Each rcell In .Range("A13:A96") ' & .Range("A" & Rows.Count).End(3).Row)
If rcell Like "*Byte Total*" Then
.Cells(rcell.Row - 1, "J").Formula = .Cells(rcell.Row - 2, "J").Formula
.Cells(rcell.Row, "J").Formula = .Cells(rcell.Row - 1, "J").Formula
j = j & "J" & rcell.Row & "+"
j = j
.Cells(rcell.Row - 1, "M").Formula = .Cells(rcell.Row - 2, "M").Formula
.Cells(rcell.Row, "M").Formula = .Cells(rcell.Row - 1, "M").Formula
m = m & "M" & rcell.Row & "+"
m = m
.Cells(rcell.Row - 1, "O").Formula = .Cells(rcell.Row - 2, "O").Formula
.Cells(rcell.Row, "O").Formula = .Cells(rcell.Row - 1, "O").Formula
o = o & "O" & rcell.Row & "+"
o = o
.Cells(rcell.Row - 1, "P").Formula = .Cells(rcell.Row - 2, "P").Formula
.Cells(rcell.Row, "P").Formula = .Cells(rcell.Row - 1, "P").Formula
p = p & "P" & rcell.Row & "+"
p = p
.Cells(rcell.Row - 1, "Q").Formula = .Cells(rcell.Row - 2, "Q").Formula
.Cells(rcell.Row, "Q").Formula = .Cells(rcell.Row - 1, "Q").Formula
q = q & "Q" & rcell.Row & "+"
q = q
End If
Next rcell
t = wsOut.Range("A" & Rows.Count).End(3).Row
j = Left(j, Len(j) - 1)
Cells(t, "J").Formula = "=" & Left(j, Len(j) - 1)
m = Left(m, Len(m) - 1)
Cells(t, "M").Formula = "=" & Left(m, Len(m) - 1)
o = Left(o, Len(o) - 1)
Cells(t, "O").Formula = "=" & Left(o, Len(o) - 1)
p = Left(p, Len(p) - 1)
Cells(t, "P").Formula = "=" & Left(p, Len(p) - 1)
q = Left(q, Len(q) - 1)
Cells(t, "Q").Formula = "=" & Left(q, Len(q) - 1)
End With
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Bookmarks