简体   繁体   中英

VBA - Check if Certain Value exists when other value is entered

I have a document which collects variety of information into specific cells.

Upon engaging an already created macro, I need a sub that checks one cell to see if a certain entry exists (lets say "Dave"). Where "Dave" has been entered it needs to check whether "Norman" has been entered into a different cell. Where it hasnt, a msg box needs to appear and exit the subroutine. Where "Norman" has been entered, then the sub routine is allowed to complete. Where something other than "Dave" is entered, the code exits the sub and continues with the original macro.

I do not want the routine to change the current entry where "Norman" needs to go.

Hope this makes sense - So far I have a very incomplete code as follows:

Sub SIFSOLCHECK()

    If instform.Range("Claim_Sol").Value = "Dave" Then
        Sheets("Proceedings").Range("Sol_Co_UF").Value = "Norman"
        MsgBox "Only Norman can assist with Dave"
        Range("Solicitor").Select
        Exit Sub
    Else
    End If
End Sub

Any help is appreciated!

Try this:

Sub SIFSOLCHECK()

    If instform.Range("Claim_Sol").Value = "Dave" Then
        If Sheets("Proceedings").Range("Sol_Co_UF").Value = "Norman" Then
            'some code
        End If
    Else
        MsgBox "Something"
    End If

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM