Statement with multiple And/Ors

cfoye130

Board Regular
Joined
Aug 12, 2008
Messages
84
I'm having trouble.... My loop has come to a cell where the first condition of the AND is true, and one of the second conditions of the OR is true (specifically the Sick Time condition). In this case I want the vba to move forward rather then exit the If, but it exits the If.

I suspect I have not written the AND/OR statement correctly as it treats only the 1st OR as the 2nd condition of the AND and not all the ORs together as the 2nd condition. Any assistance would be greatly appreciated.

Code:
 If Sheet3.Cells(I, 1) = Sheet5.Cells(C, 10) And _
                (Sheet3.Cells(I, 2) = "Vacation/Personal -  Employees Only" Or _
                Sheet3.Cells(I, 2) = "Paid Leave - Employees Only" Or _
                Sheet3.Cells(I, 2) = "Sick Time - Employees Only" Or _
                Sheet3.Cells(I, 2) = "Holiday - Employees Only") Then
                SickCheck = True
            End If
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try

Rich (BB code):
If Sheet3.Cells(i, 1) = Sheet5.Cells(c, 10) And _
                (Sheet3.Cells(i, 2) = "Vacation/Personal -  Employees Only" Or _
                Sheet3.Cells(i, 2) = "Paid Leave - Employees Only" Or _
                Sheet3.Cells(i, 2) = "Sick Time - Employees Only" Or _
                Sheet3.Cells(i, 2) = "Holiday - Employees Only") Then
                SickCheck = True
            End If
 
Upvote 0
Yeah, I edited my thread as soon as I posted it. That is how I had it. I was expermenting with out the parenthesis to see if it worked and that was the code that got pasted. So no dice, with or without the parentesis.
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,571
Members
452,927
Latest member
whitfieldcraig

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