'Insert 1 row
On Error GoTo exit_sub
'search for "Conveyor Piping"
Worksheets("imported raw data").Select
Cells.Find(What:="Conveyor Piping", After:=Range("A1"), SearchDirection:=xlPrevious).Select
'insert row after "Conveyor Piping" if it exists
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Insert shift:=xlUp
'sum Conveyor Piping
Cells.Find(What:="Conveyor Piping", SearchDirection:=xlNext, LookAt:=xlWhole).Select
x = Selection.Offset(0, 4).Address
Cells.Find(What:="Conveyor Piping", After:=Range("A1"), SearchDirection:=xlPrevious).Select
y = Selection.Offset(0, 4).Address
z = Selection.Offset(1, 6).Address
ActiveWorkbook.Worksheets("imported raw data").Range(z).Select
Selection.Value = Application.WorksheetFunction.Sum(Range(x, y))
'copy Conveyor to next tab
Worksheets("imported raw data").Select
Cells.Find(What:="Conveyor Piping", After:=Range("A1"), SearchDirection:=xlPrevious).Select
z2 = Selection.Offset(1, 6).Address
Range(z2).Select
Selection.Copy
Worksheets("Report Summary Page").Select
Range("B4").Select
ActiveSheet.paste
Application.CutCopyMode = False
Application.ScreenUpdating = True
On Error Resume Next
exit_sub:
Err.Clear
On Error GoTo exit_sub1
'search for "Non-Conveyor Piping"
Worksheets("imported raw data").Select
[COLOR=red]Cells.Find(What:="Non-Conveyor Piping", After:=Range("A1"), SearchDirection:=xlPrevious).Select[/COLOR]
'insert row after "Non-Conveyor Piping" if it exists
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Insert shift:=xlUp
'sum Non-Conveyor Piping
Cells.Find(What:="Non-Conveyor Piping", SearchDirection:=xlNext, LookAt:=xlWhole).Select
x = Selection.Offset(0, 4).Address
Cells.Find(What:="Non-Conveyor Piping", After:=Range("A1"), SearchDirection:=xlPrevious).Select
y = Selection.Offset(0, 4).Address
z = Selection.Offset(1, 6).Address
ActiveWorkbook.Worksheets("imported raw data").Range(z).Select
Selection.Value = Application.WorksheetFunction.Sum(Range(x, y))
'copy Non-Conveyor Piping to new tab
Worksheets("imported raw data").Select
Cells.Find(What:="Non-Conveyor Piping", After:=Range("A1"), SearchDirection:=xlPrevious).Select
z3 = Selection.Offset(1, 6).Address
Range(z3).Select
Selection.Copy
Worksheets("Report Summary Page").Select
Range("B5").Select
ActiveSheet.paste
Application.CutCopyMode = False
Application.ScreenUpdating = True
On Error Resume Next
exit_sub1:
Err.Clear
'sum Pipe Supports
On Error GoTo exit_sub2
Worksheets("imported raw data").Select
Cells.Find(What:="Pipe Supports", SearchDirection:=xlNext, LookAt:=xlWhole).Select
x = Selection.Offset(0, 4).Address
Cells.Find(What:="Pipe Supports", After:=Range("A1"), SearchDirection:=xlPrevious).Select
y = Selection.Offset(0, 4).Address
z = Selection.Offset(1, 6).Address
ActiveWorkbook.Worksheets("imported raw data").Range(z).Select
Selection.Value = Application.WorksheetFunction.Sum(Range(x, y))
'Copy Pipe Supports to new tab
Worksheets("imported raw data").Select
Cells.Find(What:="Pipe Supports", After:=Range("A1"), SearchDirection:=xlPrevious).Select
z1 = Selection.Offset(1, 6).Address
Range(z1).Select
Selection.Copy
Worksheets("Report Summary Page").Select
Range("B6").Select
ActiveSheet.paste
Application.CutCopyMode = False
Application.ScreenUpdating = True
On Error Resume Next
exit_sub2:
Err.Clear