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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA macro question

Status
Not open for further replies.

skeptiq

Programmer
Dec 8, 2005
1
US
Hello, I am new to programming in VBA, and I am attempting to create a macro that will do the following:

Sheet1 Column "A" contains text strings
Sheet2 Column "A" contains text strings

I would like to get Sheet2 Column A, Row 1 and search for the string in Sheet1 Column A. The problem is the text in Sheet1 is not always an exact match. For example:
Sheet1 A,23: R12345
Sheet2 A,1: 12345

If the macro works how I would like, it should identify Sheet1 A,23 as a match.

I have tried using:
Code:
If Not (IsError(Application.WorksheetFunction.Search(OrderPart, MasterPart))) Then
      Found = True
      Worksheets(MasterSheetName).Range("B" & j).Value = OrderNumber
    End If
But get the following error when running the macro:
Run-time error '1004':
Unable to get the Search property of the WorksheetFunction class.

Any assistance would be great! As I stated, I have only been playing around with this for a short time (like about 2 days).

Regards,
Charles
 
The 4th argument in the FIND method in excel is:

LookAt Optional Variant. Can be one of the following XlLookAt constants: xlWhole or xlPart.


xlPart allows searching for partial matches...


Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top