Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignore Dashes In Find Statement

Status
Not open for further replies.

dar149

MIS
Mar 5, 2002
117
US
I have a spreadsheet where, through code, I find a particular part number and return information based on the result of the find statement. If I take the dashes out of the part number I'm searching for, is there a way to code the search so that dashes are ignored in the data I'm searching? For example, if I'm searching for plt1, I want it to find plt-1. I haven't been able to find a way to do that. We don't want to take the dashes out of the data being searched.

Thanks...
 
dar,

This code will take a Social Security Number and subtract one.

ex: 123-45-6789 = 123-45-6788

Code:
Me.SomeField = Format(CLng(Mid(Me.SomeField, 1, 3)) * 1000000 + _
                      CLng(Mid(Me.SomeField, 5, 2)) * 10000 + _
                      CLng(Mid(Me.SomeField, 8, 4) - 1, "000-00-0000")

Wayne
 
Hi dar149,

I don't think you can take the dashes out on the fly during a search but a couple of other possibilities:

Could you create another column in your sheet for part numbers without dashes which you could search (consider the worksheet SUBSTITUTE function or the VBA (2K and later) Replace function).

Or, perhaps, hold part number without dashes, but FORMAT them with dashes on all output media.

If you really want to keep the dashes I presume they have significant meaning and plt-1 would not appear as pl-t1. If this is so could you not search for plt-1 when plt1 was input? In other words change the single value you want to compare rather than every value you want to comapre against.

Enjoy,
Tony
 
Thanks for the info... Since I can't take out dashes on the fly during a search, I'll see if we can get by with creating a second column without dashes to do the search.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top