I have a macro that compares the datas in column A and B of the sheets 'Patches' and 'NA' and deletes the data in the 'Patch' sheet that matches with the ones in the 'NA' sheet.
It works perfect except for one issue. There is a patch ,
'Must Upgrade Product SP Before Applying Patch' in the 'Patches' sheet for a lot of machines whereas the same patch is present for only on machine (D) in the 'NA' sheet (Marked in Red).
when i run the macro all the 'Must Upgrade Product SP Before Applying Patch' is deleted in the 'patches' sheet whereas it must be deleted only for the machine D.
Sub NA()
Const lngStartRow As Long = 2 'Starting data row number. Change to suit.
Dim lngMyCol As Long, _
lngMyRow As Long
Dim xlnCalcMethod As XlCalculation
With Application
xlnCalcMethod = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
lngMyCol = Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
lngMyRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Columns(lngMyCol)
With Range(Cells(lngStartRow, lngMyCol), Cells(lngMyRow, lngMyCol))
.Formula = "=IF(ISERROR(VLOOKUP(B" & lngStartRow & ",NA!B:B,1,FALSE)),"""",NA())"
ActiveSheet.Calculate
.Value = .Value
End With
On Error Resume Next 'Turn error reporting off - OK to ignore 'No cells found' message
.SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete
On Error GoTo 0 'Turn error reporting back on
.Delete
End With
With Application
.Calculation = xlnCalcMethod
.ScreenUpdating = True
End With
MsgBox "NA patches have been deleted.", vbInformation
End Sub
can any one please help me on this? Thanks in advance!!
Bookmarks