Help on If and Or statement VBA

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a current VBA that works as intended see below:

VBA Code:
    Dim chk

'check if run for today already
If Int(Range("B8")) <> Date Then
    chk = MsgBox("Import ST was not run for today, do you still want to continue?", vbYesNo)
    If chk = vbNo Then
        Exit Sub
    End If
End If

I want to add a second criteria so if B8 or B11 dont equal DATE to trigger that msgbox. i tried so many different combinations with no luck. is there anything easy you can see that would solve my dilemna?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Be careful with your logic. Do you mean

B8 OR B11 don't equal DATE
This means at least one of them does not equal Date

or

B8 AND B11 don't equal DATE
This means neither one of them equals Date

Just a wild guess but I think you want the second one.

Rich (BB code):
If Int(Range("B8")) <> Date And Int(Range("B11")) <> Date Then
 
Upvote 0
Solution
Maybe unless I am confusing myself I have the below condition

Run date 1: 03/30/22 1:46PM
Run date 2: 03/31/22 5:58PM

so if one of the 2 dont equal todays date to kick a warning
 
Upvote 0
In that case you want

Rich (BB code):
If Int(Range("B8")) <> Date Or Int(Range("B11")) <> Date Then
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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