lundi 15 mars 2021

Loop through data, copy to new sheet if conditions are meet

Data sheet

Report

I will like to be able to go through "data sheet" starting in row #10 and if structural(1) has been returned then go to Structural (2). if Structural (2) has been returned then go to Structural (3). if structural (3) has not been returned by consultant then copy Submitted Date and Days with consultant to sheet "Report" (paste as values only). then go to the next row and do same process.

lastly, if "(1) Structural: Submitted" empty then just add #N/A to the report.

the goal is to make a report from projects that are still with the consultant and also indicate how many days with consultant.

Thank you all so much for any help!

lrow = Sheets("PROJECTS").Range("B" & Rows.Count).End(xlUp).Row
Set datasht = ThisWorkbook.Sheets("PROJECTS")
Set reportsht = ThisWorkbook.Sheets(sheetname & " " & mydate)
Set rng = Application.Range("i10:q" & lrow)

Range("i10").Activate
For Each x In rng
        If Not IsEmpty(ActiveCell.Value) And Not IsEmpty(ActiveCell.Offset(0, 2).Value) = True Then
                ActiveCell.Offset(0, 3).Select
        ElseIf IsEmpty(ActiveCell.Value) And IsEmpty(ActiveCell.Offset(0, 2).Value) = True Then
                ActiveCell.Offset(0, 3).Activate
        ElseIf Not IsEmpty(ActiveCell.Value) And IsEmpty(ActiveCell.Offset(0, 2).Value) = True Then
                ActiveCell.Select
                Range(ActiveCell, ActiveCell.End(xlToRight)).Select
                Selection.Copy
                erow = Sheets(sheetname & " " & mydate).Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).Row
                Worksheets("PROJECTS").Paste Destination:=Sheets(sheetname & " " & mydate).Cells(erow, 7) 'need to place value only
                Application.CutCopyMode = False
        End If
        Next

Aucun commentaire:

Enregistrer un commentaire