Results 1 to 8 of 8

Macro for Comparison

Threaded View

sarajun_88 Macro for Comparison 01-12-2015, 03:07 AM
Marc L Re: Macro for Comparison 01-12-2015, 05:07 AM
sarajun_88 Re: Macro for Comparison 01-12-2015, 05:48 AM
pbengtss Re: Macro for Comparison 01-12-2015, 07:57 AM
sarajun_88 Re: Macro for Comparison 01-13-2015, 01:06 AM
pbengtss Re: Macro for Comparison 01-14-2015, 02:46 AM
sarajun_88 Re: Macro for Comparison 01-14-2015, 03:27 AM
pbengtss Re: Macro for Comparison 01-16-2015, 03:41 AM
  1. #1
    Registered User
    Join Date
    11-22-2014
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    83

    Macro for Comparison

    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!!
    Attached Files Attached Files
    Last edited by sarajun_88; 01-12-2015 at 05:46 AM. Reason: Code

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. comparison macro
    By beatrice25 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-29-2008, 03:14 PM
  2. Comparison Macro
    By seanmartin26 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2006, 05:57 PM
  3. RE: Comparison Macro
    By Tom Ogilvy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2006, 01:20 PM
  4. Comparison Macro
    By aceensor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2005, 03:13 PM
  5. [SOLVED] Macro for a comparison
    By mike b in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2005, 03:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1