Niranjanrajrishi
Member
Code:
Sub ProdSel()
Dim lngStart As Long, lngEnd As Long
Dim rng As Range
Sheets("Data").Select
Range("N2").Select
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
Rws = Cells(Rows.Count, "A").End(xlUp).Row
lngStart = Sheets("Macro").Range("K14") 'assume this is the start date
lngEnd = Sheets("Macro").Range("L14") 'assume this is the end date
Part1 = Sheets("Macro").Range("J14") 'assume this is the end date
Columns("A:V").AutoFilter Field:=4, _
Criteria1:="=" & Part1
Columns("A:V").AutoFilter Field:=11, _
Criteria1:="=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="=" & lngEnd
Columns("A:V").AutoFilter Field:=4, _
Criteria1:="=" & Part1
Sheets("Data").Activate
Rws = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range(Cells(2, "W"), Cells(Rws, "W")).SpecialCells(xlCellTypeVisible)
If Not rng Is Nothing Then rng.Value = "Required"
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
Rws = Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("$A$1:$AP$" & Rws).AutoFilter Field:=42, Criteria1:="", Operator:=xlFilterValues
Set rng = ActiveSheet.Range("$A$2:$AP$" & Rws).SpecialCells(xlCellTypeVisible)
If Not rng Is Nothing Then
Set rng = Nothing
Set rng = Range(Cells(2, "AP"), Cells(Rws, "AP")).SpecialCells(xlCellTypeVisible)
If Not rng Is Nothing Then rng.Value = "Delete"
End If
With ActiveSheet
.AutoFilterMode = False
End With
Need support to delete those data which does not match with the Criteria set in the Macro sheet.
Product ID in J column (Macro sheet)
Date from in K column (Macro sheet)
Date from in L column (Macro sheet)
The product IDs will be multiple (maximum 10) and the respective date shoould match in the Data sheet. Any Product ID which does not fall under the date criteria (from Date and To date) should be deleted.
Can you please help me?