IF, OR statement in VBA

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
Hi, I have my code working well but want to expand it. Need it to therefore become an OR statement as the two conflict at present

Rich (BB code):
Dim n as Name
 
For Each n In ActiveWorkbook.Names
    If n.RefersTo Like "*[[]*" Then n.Delete
    If n.RefersTo Like "*REF!*" Then n.Delete
Next n

If the first condition is met, n is deleted and so the second if statement fails as the object has gone

I need to expand it so that both IF statements can be treated as an OR.

IF x=y OR a=b THEN

Simple request I hope...
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
A greater understanding of OR type use would help me alot.

How could I have multiple OR statements with various conditions. Would also like to use AND
 
Upvote 0
I tried that. Gave me error. But now it works. Bizarre!

I will investigate ElseIf statements as well, they seem to be the answer for multiple IF, along with select case

Thanks guys!
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,337
Members
452,907
Latest member
Roland Deschain

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