View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Search text string for ssn and copy to new column

On Thu, 27 Dec 2007 21:28:10 -0500, "Rick Rothstein \(MVP - VB\)"
wrote:

Assuming there is nothing else, numeric or text, in the string with that
format, you could use the formula:

=MID(A1,SEARCH("???-??-????",A1),11)

To prevent the #VALUE! error (with having to devise a complicated IF
test),
you modify your formula like this...

=MID(A1,SEARCH("???-??-????",A1&" - - "),11)

Rick


Thanks for the addition. I usually let the requestor decide what he wants
if the substring is not present in the searched string.


Normally, I would agree with that approach; but, unless I am missing
something obvious (always a distinct possibility), any such test would be
somewhat longish and/or add a duplicate calling of the result formula, so I
figured I would offer (mainly for the archives), the "give the function
something to find" method of getting around that situation.

Rick


One approach, which I tend to use myself, is to use conditional formatting. I
can either "white-out" the result, or use formatting of interior and font to
make the error really stand out. The cell formula stays the same.
--ron