Cancel Save

Moseth

New Member
Joined
Sep 5, 2018
Messages
12
I Currently have this :

If Application.Sheets("dhdn").Range("D11").Value = "Yes" And _
Application.Sheets("fgdfd").Range("I11").Value = "" Then
Cancel = True


so this currently means if cell D11 is marked a yes but I11 is left as blank then the save opeartion will not allow.

What I want is the following:
If Cell D11 is marked as yes and I11 is left blank, Cell B41 cant be left blank otherwise save will fail.

How do I incorporate this in the code?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You didn't mention which sheet to check cell B41 so I guessed.

You can just use the "And" operator again.

Code:
IF Application.Sheets("dhdn").Range("D11").Value = "Yes" And _
Application.Sheets("fgdfd").Range("I11").Value = "" And _
Application.Sheets("fgdfd").Range("B41").Value = "" Then
Cancel =True
End If
 
Upvote 0

Forum statistics

Threads
1,214,539
Messages
6,120,100
Members
448,944
Latest member
SarahSomethingExcel100

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