target value multiple criteria

erutherford

Active Member
Joined
Dec 19, 2016
Messages
449
Trying to get 2 criteria to work in target.value scenario. Thought it would look like this, but nope "type mismatch" error. I know I can just write a separate one for "NA", but trying to learn to be efficient in writing code.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Application.EnableEvents = False

    If Not Intersect(Target, Range("B:B")) Is Nothing Then
        If Target.Cells.Value = " " Or IsEmpty(Target) Then GoTo exitsub
    'ok entries
        'Jumps to Col.C - Estimate
        If Target.Value = "ok" Or "NA" Then Target.Offset(0, 1).Value = "0"
        'Jumps to Col J - Situation Code
        If Target.Value = "ok" Or "NA" Then Target.Offset(0, 8).Value = "4"
        'Auto drops to next row
        If Target.Value = "ok" Or "NA" Then Target.Offset(1, 0).Select
        'Moves cursor to Col.C
        If Target.Value <> "ok" Or "NA" Then Target.Offset(0, 1).Select
         
   
    End If
exitsub:
    Application.EnableEvents = True

    Worksheets("RptChklst").Columns("B:B").WrapText = True _

End Sub

thanks for the look
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Lots of detailed rules, but if it avoids problems
Sometimes the smallest detail creates the biggest problem. The use of <> with Or was a mistake that I made once which took a long time to find to find the cause.
 
Upvote 0

Forum statistics

Threads
1,215,749
Messages
6,126,661
Members
449,326
Latest member
asp123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top