Set wscf = Sheets(Range("G3").Value) Set wsjr = Sheets("Start Page") lastRow =…
- User
Set wscf = Sheets(Range("G3").Value) Set wsjr = Sheets("Start Page") lastRow = wscf.Cells(Rows.count, "J").End(xlUp).Row
For i = 5 To lastRow If wscf.Cells(i, "I") = "" Then If copyRange Is Nothing Then Set copyRange = wscf.Range("J" & i) Else Set copyRange = Union(copyRange, wscf.Range("J" & i)) End If End If Next i
If Not copyRange Is Nothing Then wsjr.Range("F9").Resize(copyRange.Rows.count, 1).Value = copyRange.Value End If
The above code works perfectly. However with all the vales in column B containing a Text value, and all the values in column H containing a date value, I would like to exclude the following from the copyRange; wscf.Cells(i, "B") = "Service" And wscf.Cells(i, "H") < Date + 90
- Assistant
To exclude the values that meet the conditions
wscf.Cells(i, "B") = "Service"andwscf.Cells(i, "H") < Date + 90, you can modify the code as follows:Set wscf = Sheets(Range("G3").Value) Set wsjr = Sheets("Start Page") lastRow = wscf.Cells(Rows.Count, "J").End(xlUp).Row For i = 5 To lastRow If wscf.Cells(i, "I") = "" Then If (wscf.Cells(i, "B") <> "Service") And (wscf.Cells(i, "H") >= Date + 90) Then If copyRange Is Nothing Then Set copyRange = wscf.Range("J" & i) Else Set copyRange = Union(copyRange, wscf.Range("J" & i)) End If End If End If Next i If Not copyRange Is Nothing Then wsjr.Range("F9").Resize(copyRange.Rows.Count, 1).Value = copyRange.Value End IfThis code adds an additional condition to the
Ifstatement that checks ifwscf.Cells(i, "B")is not equal to "Service" andwscf.Cells(i, "H")is greater than or equal toDate + 90. Only if both of these conditions are met, the corresponding range ("J" & i) is added tocopyRange.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.