Apply 2 options for the code to look at

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,237
Office Version
  1. 2007
Platform
  1. Windows
Hi,

I am using the working code shown below & the line of code in Red is where i need to edit.
I also need to include KDX 2 TOOL but how do i write it please

Rich (BB code):
Private Sub Kdx2_Click()
    
    If ActiveCell.Column <> 1 Then
      MsgBox "YOU MUST SELECT A CUSTOMER IN COLUMN A FIRST", vbCritical, "CUSTOMER WAS NOT SELECTED"
    Exit Sub
    End If
    
    If ActiveCell.Offset(0, 8).Value = "KDX 2 DEVICE " Then
    Call KDX2TRANSFER
    Else
    MsgBox "KDX 2 WAS NOT USED ON THIS VEHICLE", vbCritical, "KDX 2 WAS NOT USED"
    End If
   
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Simply add an "OR" clause, i.e.
VBA Code:
    If (ActiveCell.Offset(0, 8).Value = "KDX 2 DEVICE ") Or (ActiveCell.Offset(0, 8).Value = "KDX 2 TOOL") Then
 
Upvote 0
Solution
Another approach would be to use the Select Case statement.
VBA Code:
Private Sub Kdx2_Click()
    
    If ActiveCell.Column <> 1 Then
        MsgBox "YOU MUST SELECT A CUSTOMER IN COLUMN A FIRST", vbCritical, "CUSTOMER WAS NOT SELECTED"
        Exit Sub
    End If
    
    'If ActiveCell.Offset(0, 8).Value = "KDX 2 DEVICE " Then
    '    Call KDX2TRANSFER
    'Else
    '    MsgBox "KDX 2 WAS NOT USED ON THIS VEHICLE", vbCritical, "KDX 2 WAS NOT USED"
    'End If
   
    Select Case Trim(ActiveCell.Offset(0, 8).Value)
    Case "KDX 2 DEVICE", "KDX 2 TOOL"
        Call KDX2TRANSFER
    Case Else
        MsgBox "KDX 2 WAS NOT USED ON THIS VEHICLE", vbCritical, "KDX 2 WAS NOT USED"
    End Select
End Sub
 
Upvote 0
Now done using Joe4 advice.
I see you also added ( )

Thanks
 
Upvote 0
I see you also added ( )
They really aren't necessary, but I like to add them to clarify any confusion over what the order of events is.
It just erases any doubt anyone may have about it.
 
Upvote 0

Forum statistics

Threads
1,215,637
Messages
6,125,963
Members
449,276
Latest member
surendra75

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