View Single Post
  #24   Report Post  
Posted to microsoft.public.excel.programming
KHashmi316[_18_] KHashmi316[_18_] is offline
external usenet poster
 
Posts: 1
Default (in)definite article and leading/trailing space remover needed


JMB Wrote:
The End If has to be there. I think the following line may be the
issue

And (InStr(1, x.Value, " ", vbTextCompare) - 1 0) Then
x.Value = Trim(Replace(x.Value, y, "", 1, 1, vbTextCompare))
Exit For
End If


If Then statements can appear on one line. If so, you don't need the
End
If. If the IF/THEN is being treated as one line then the Exit For will
be
outside of the IF statement, causing the macro to end after looping
through
only the first element of Array1 (which is "The"). In this case, the
Then
statement has two lines of code requiring the End If.

Make sure the code appears exactly as I've written it above. Also,
you
don't need to include lowercase "a" "an" "the" in the array. For
comparison
purposes the macro converts everything to uppercase (but doesn't change
how
it appears in the spreadsheet).



Hi, JMB:

Hoorah -- that worked! One more tweak I was thinking about was a way to
copy whatever (in)definite article the macro finds at the beginning of
the title, and concatenate it to the end of the title, such as:

The Scarlet Letter

to:

Scarlet Letter, The

By and large, however, article removing was my main concern. If you
have a quick suggestion, that's fine, but this new tweak is not that
critical.

Thx, again!


--
KHashmi316


------------------------------------------------------------------------
KHashmi316's Profile: http://www.excelforum.com/member.php...o&userid=10439
View this thread: http://www.excelforum.com/showthread...hreadid=378854