Sub PublishE()
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim SourceData As Worksheet
Dim Dashboard As Worksheet
Dim searchString As Variant
Dim lastSourceRow As Long
Dim startSourceRow As Long
Dim lastTargetRow As Long
Dim sourceRowCounter As Long
Dim columnToEval As Long
Dim columnCounter As Long
Dim columnsToCopy As Variant
Dim columnsDestination As Variant
Set SourceData = ThisWorkbook.Worksheets("Execution Template")
Set Dashboard = ThisWorkbook.Worksheets("Test")
columnsToCopy = Array(2, 4, 5, 7, 18, 19, 19, 27, 28, 28, 33, 34, 34, 45, 46, 46, 51, 60, 65)
columnsDestination = Array(1, 2, 3, 4, 7, 8, 1304, 9, 10, 1305, 11, 12, 1306, 13, 14, 1307, 17, 19, 5)
searchString = ""
startSourceRow = 3
columnToEval = 9
lastTargetRow = Dashboard.Cells(Dashboard.Rows.Count, 1).End(xlUp).Row 'move this out of the loop
lastSourceRow = SourceData.Cells(SourceData.Rows.Count, 1).End(xlUp).Row
For sourceRowCounter = startSourceRow To lastSourceRow
If SourceData.Cells(sourceRowCounter, columnToEval).Value = searchString Then
For columnCounter = 0 To UBound(columnsToCopy)
Dashboard.Cells(lastTargetRow, columnsDestination(columnCounter)).Offset(1, 0).Value = _
SourceData.Cells(sourceRowCounter, columnsToCopy(columnCounter)).Value
Next columnCounter
lastTargetRow = lastTargetRow + 1 'next destination row
End If
Next sourceRowCounter
searchString = "AWENG REVIEW"
startSourceRow = 3
columnToEval = 9
lastTargetRow = Dashboard.Cells(Dashboard.Rows.Count, 1).End(xlUp).Row 'move this out of the loop
lastSourceRow = SourceData.Cells(SourceData.Rows.Count, 1).End(xlUp).Row
For sourceRowCounter = startSourceRow To lastSourceRow
If SourceData.Cells(sourceRowCounter, columnToEval).Value = searchString Then
For columnCounter = 0 To UBound(columnsToCopy)
Dashboard.Cells(lastTargetRow, columnsDestination(columnCounter)).Offset(1, 0).Value = _
SourceData.Cells(sourceRowCounter, columnsToCopy(columnCounter)).Value
Next columnCounter
lastTargetRow = lastTargetRow + 1 'next destination row
End If
Next sourceRowCounter
searchString = "CHANGE IN WORK SCOPE"
startSourceRow = 3
columnToEval = 9
lastTargetRow = Dashboard.Cells(Dashboard.Rows.Count, 1).End(xlUp).Row 'move this out of the loop
lastSourceRow = SourceData.Cells(SourceData.Rows.Count, 1).End(xlUp).Row
For sourceRowCounter = startSourceRow To lastSourceRow
If SourceData.Cells(sourceRowCounter, columnToEval).Value = searchString Then
For columnCounter = 0 To UBound(columnsToCopy)
Dashboard.Cells(lastTargetRow, columnsDestination(columnCounter)).Offset(1, 0).Value = _
SourceData.Cells(sourceRowCounter, columnsToCopy(columnCounter)).Value
Next columnCounter
lastTargetRow = lastTargetRow + 1 'next destination row
End If
Next sourceRowCounter
searchString = "FCO REQ'd"
startSourceRow = 3
columnToEval = 9
lastTargetRow = Dashboard.Cells(Dashboard.Rows.Count, 1).End(xlUp).Row 'move this out of the loop
lastSourceRow = SourceData.Cells(SourceData.Rows.Count, 1).End(xlUp).Row
For sourceRowCounter = startSourceRow To lastSourceRow
If SourceData.Cells(sourceRowCounter, columnToEval).Value = searchString Then
For columnCounter = 0 To UBound(columnsToCopy)
Dashboard.Cells(lastTargetRow, columnsDestination(columnCounter)).Offset(1, 0).Value = _
SourceData.Cells(sourceRowCounter, columnsToCopy(columnCounter)).Value
Next columnCounter
lastTargetRow = lastTargetRow + 1 'next destination row
End If
Next sourceRowCounter
searchString = "PLANNING CP"
startSourceRow = 3
columnToEval = 9
lastTargetRow = Dashboard.Cells(Dashboard.Rows.Count, 1).End(xlUp).Row 'move this out of the loop
lastSourceRow = SourceData.Cells(SourceData.Rows.Count, 1).End(xlUp).Row
For sourceRowCounter = startSourceRow To lastSourceRow
If SourceData.Cells(sourceRowCounter, columnToEval).Value = searchString Then
For columnCounter = 0 To UBound(columnsToCopy)
Dashboard.Cells(lastTargetRow, columnsDestination(columnCounter)).Offset(1, 0).Value = _
SourceData.Cells(sourceRowCounter, columnsToCopy(columnCounter)).Value
Next columnCounter
lastTargetRow = lastTargetRow + 1 'next destination row
End If
Next sourceRowCounter
SourceData.Activate
End If
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Bookmarks