Excel Userform - Check and delete another column from the "for each"

CoryMelth

New Member
Joined
Jul 3, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello.

I have an excel userform code that copy each row that match with
VBA Code:
If I.Value2 = "Chicou" Then
I would like to add a If function that skip or delete the row fit with the actual date or futur date from the actual day.

I've start from this
Code:
With Workbooks("data_dump.xlsx").Worksheets("Chicou") 'reference target sheet
    For Each I In Workbooks(NDR_FileName).Worksheets("Notes").Range("A6:A10000") 'loop through Sheet9 "A2:A1000" cells
        If I.Value2 = "Chicou" Then
            I.EntireRow.Copy
            .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues ' all “dots” are making following members/object referencing the object referenced in “With...”
        End If
    Next
End With

To this

VBA Code:
    With Workbooks("data_dump.xlsx").Worksheets("Chicou") 'reference target sheet
        For Each I In Workbooks(NDR_FileName).Worksheets("Notes").Range("A6:A10000")
            If I.Value2 = "Chicou" Then
                If Cells.Range("F", I) <= Date Then
                    'This row with F column fit with the actual date OR futur, do nothing, skip.
                Else
                    'Copy row.
                    I.EntireRow.Copy
                    .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
                End If
            End If
        Next
    End With


Anyone could give me a tips ?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top