having 2 conditions with Replace Function

keith05281967

Board Regular
Joined
May 6, 2011
Messages
68
Greetings,

I'm using a Replace function ***in vba code*** to remove a word from a file name and it works perfectly. Can I have 2 conditions in a Replace function?

currently:
sFile = Replace(sFile, "Bob.", "")

below is my attempt to add a second condition....vbe didn't like my syntax.

sFile = Replace(sFile, "Bob.", "") Or Replace(sFile, "Bob_", "")

Sometimes the word to be removed is followed w/ a period and sometimes an underscore, but either way i want to remove it.

excel 07
thanks,
Keith
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Would this work:
Code:
sFile = Replace(sFile, "Bob*", "")
i.e. using a wild card?
 
Upvote 0
Dan - I just tested it and it doesn't work. I think because there is more to the file name after the . or _

the files look something like "Actionable_FILENAME.xlsx"
or "Actionable.FILENAME.xlsx"

which is why i'm looking for a way to get a second condition in the argument of the Replace function.

Keith
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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