Hello, I've attempted to modify this code (See below) to check a cell in Worksheet "Execution Template" column #9 (I) for multiple criteria (a total of 5 different ones) then copy specific cells in that row;before going to the next cell. After copying the specific cells in the row that met the criteria in column #9 (I) they would be pasted in sequence into worksheet "TEST" (Gantt Chart). Unfortunately, I don't possess the skills to be successful at such an endeavor. My attempts have produced the code going through the complete loop for a single criteria then copying that row's specific cells before going to the next criteria and repeating the same process. This unfortunately has resulted in the pasting of the cells out of sequence. This makes it impossible to follow any work that belongs to the same JOB # on the Gantt Chart. I would appreciate any and all assistance on this issue. Thank you.
Sub CopyPaste()
Dim SourceData As Worksheet
Dim Dashboard As Worksheet
Dim searchString As String
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("Source Data")
Set Dashboard = ThisWorkbook.Worksheets("Dashboard")
columnsToCopy = Array(7, 8, 11)
columnsDestination = Array(2, 3, 4)
searchString = "New"
startSourceRow = 3
columnToEval = 45
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 Sub
Bookmarks