Results 1 to 1 of 1

Condition statement isnt working , any ideas ?

Threaded View

  1. #1
    Registered User
    Join Date
    07-01-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    66

    Exclamation Condition statement isnt working , any ideas ?

    I would like to highlight certain data (ID) and pop out a message based on the following IF statement

    I have two Workbook - Book 1 and Book 2
    I need to check the ID ( Book1 - Column S) against ( Book 2 - Column J) and execute IF statement

    If (ID is found) ,
    if (Book 2 - Remarks Column"P") = Open A/R OR Merged Then
    Highlight "Blue" (row in book1)
    Message pop out "Confirm Delete?"
    else
    Highlight "Green" (row in book1)
    Else (ID is not found)
    Highlight "Red" (row in book1)
    Any ways to solve this ?

    Thanks in advance

    Need it urgently

    Cross Ref: http://www.mrexcel.com/forum/excel-q...ml#post4226874


    Sub CheckIDs()
    
    
        On Error Resume Next
        Dim rng As Range, str As String
        Dim Wkb1, Wkb2 As Workbook
        
        Set Wkb1 = Workbooks("Book1") ' replace with name of open workbook 1
        Set Wkb2 = Workbooks("Book2") ' replace with name of open workbook 2
        
        For Each rng In Wkb1.ActiveSheet.UsedRange.Column("S").Cells
            str = WorksheetFunction.VLookup(rng.Value, Wkb2.ActiveSheet.UsedRange.Columns("J:P"), 7, False)
            If Err.Description = "" Then ' ID found...
                    If str = "Open A/R OR Merged" Then
                        rng.Interior.Color = RGB(0, 0, 255) ' blue
                        Select Case MsgBox("Confirm delete?", vbYesNo)
                            Case vbYes
                            ' what to do here????
                            Delete row in Book 1 (ID row) 
                            
                            Case vbNo
                            ' what to do here???
                             continue the loop till all the ids are check
    
                        End Select
                    Else
                        rng.Interior.Color = RGB(0, 255, 0) ' green
                    End If
            Else ' no ID found...
                Err.Clear
                rng.Interior.Color = RGB(255, 0, 0) ' red
            End If
        Next rng
    
    
    End Sub
    Last edited by fluffyvampirekitten; 07-27-2015 at 09:30 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error message if there is a certain statement in a cell
    By Engineeronamission in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2014, 07:02 AM
  2. How to highlight cell using if statement....
    By jaysakle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-08-2014, 03:17 AM
  3. Error message in if statement - reg
    By mvel_sky in forum Excel General
    Replies: 2
    Last Post: 04-25-2012, 08:49 AM
  4. Message box if statement
    By mcinnes01 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2010, 04:32 AM
  5. Replies: 3
    Last Post: 05-15-2009, 10:11 AM
  6. IF Statement Validation with Message Box?
    By Armanian in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-12-2009, 04:44 PM
  7. Why does this statement give an error message?
    By George Furnell in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2006, 10:50 AM

Tags for this Thread

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