Using an If stmt with an "Or"

keith05281967

Board Regular
Joined
May 6, 2011
Messages
68
Greetings,

I have some code that populates a column based on the file name. It strips out the extension and changes the "day" in the date to 01. That part works fine.

I'm having a problem when I tried to add another condition with the "Or".
I'm getting "object required" error 424. I'm sure i'm overlooking something in the syntax.


sFile = ActiveWorkbook.Name
sFile = Replace(sFile, ".xls", "")
If InStr(1, sFile, "CAT_") Or sFile.Value = "BIGDOG" Then
Mid(sFile, Len(sFile2) - 5, 2) = "01"
End If

any help is appreciated.

thanks,
Keith
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
sfIle is a string. Try something like this...

If InStr(1, sFile, "CAT_") Or sFile = "BIGDOG" Then


Or this if you want to make it case insensitive.
If InStr(1, sFile, "CAT_") Or UCase(sFile) = "BIGDOG" Then
 
Upvote 0

Forum statistics

Threads
1,224,588
Messages
6,179,743
Members
452,940
Latest member
rootytrip

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