View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default find text within string and then delete

If InStr(1, UCase(c.Value), "REPORT") Then

The InStr function has two optional arguments... the first which is a
starting position for the search (InStr is an unusual function in its having
an optional *first* argument) and, if the first argument is specified, a
fourth which allows you to make it perform a non case sensitive search. So,
using your UCase approach as shown above, the function call could have been
simplified to this...

If InStr(UCase(c.Value), "REPORT") Then

but using the first and fourth arguments would allow us to eliminate the
UCase function call...

If InStr(1, c.Value, "Report", vbTextCompare) Then

where the letters in the word "Report" can be in any case (here I use the
more friendly looking, at least to me, "proper" case).

--
Rick (MVP - Excel)