Option Compare Text

  • Thread starter Thread starter Graham
  • Start date Start date
G

Graham

Hi,

I am trying to perform a certain operation via AutoOpen
that will only run if the workbook name is "template" for
example. If the workbook name is anything else I would
like AutoOpen to ignore the procedure. I have been advised
to use Option Compare Text, but I don't know how! Help
please!

Thanks
Graham
 
Hi
maybe something like
If LCase(activeworkbook.name) = "template" then
'do something
end if
 
Graham,

If you put 'Option Compare Text' at the very top of the code
module (not the procedure), all text comparisons in that module
will be case-insensitive. Short of that, you can use StrComp to
compare two strings and see if they are equal. E.g.,

If StrComp(ActiveWorkbook.Name, "template", vbTextCompare) = 0
Then
' strings are equal
Else
' strings are not equal
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top