Add an If check before the main code runs advice

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
I have a code which transfers values from the open workbook to another workbook & all works fine.
I now need to add an if statement Before the main code runs.

Customers name is always in column A
The value to check if present or not is always in column I
The value to check for is KDX 2

So it should work like this.

A customer is selected in column A
The code must look in column I on this customers row & if KDX 2 is present then allow the rest of the code which i have currently in use.
If there is any other value in column I then show MsgBox & stop the code from running.

I think i can do it it the customer was selected in the same cell in column A every time BUT unsure when it could be anywhere
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
As a test i did this but always shows NO

Rich (BB code):
    If ActiveCell.Offset(0, 9).Value = "KDX 2" Then
    MsgBox "YES"
    Else
    MsgBox "NO"
    End If
 
Upvote 0
Ive now sorted the above issue out by using the following codewhich works fine.
Currently it will run even if i select another cell then iof offsets etc.
Im looking to make sure column A is first selected then continue


Rich (BB code):
Private Sub Kdx2_Click()
   
    If ActiveCell.Offset(0, 8).Value = "KDX 2" Then
    Call KDX2TRANSFER
    Else
    MsgBox "KDX 2 WAS NOT USED ON THIS VEHICLE", vbCritical, "KDX 2 WAS NOT USED"
    End If
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,984
Members
449,092
Latest member
Mr Hughes

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