PDA

View Full Version : [SOLVED] Search a string to contains....



ValerieT
02-06-2014, 08:14 AM
Hello

I am struggling with stupid problems, sorry to bother you with beginner questions

I've got checks on column headers (to insure essential information exists):


Set Found = Rows(1).Find(What:="FTE", After:=Cells(1, 5))



What syntax will give me a Found =OK, based on header "contains" FTE, and no "match exactly" like it does now?

lecxe
02-06-2014, 01:56 PM
Hi Valerie

Please look at the help of the Find() method of the Range object to know what options are available to you.

In this case, maybe you want:



Set Found = Rows(1).Find( _
What:="FTE", _
After:=Cells(1, 5), _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)

ValerieT
02-07-2014, 03:12 AM
Thanks a lot.

I always check the help before, but in that case, see below the help I've got. Should have I understood that it doesn't stops at Arg3, and that there always can be more optional arguments?




Excel Developer Reference



WorksheetFunction.Find Method



Finds specific information in a worksheet. Syntax
expression.Find(Arg1, Arg2, Arg3)
expression A variable that represents a WorksheetFunction object.
Parameters


Name

Required/Optional

Data Type

Description



Arg1

Required

String

The name of the worksheet.



Arg2

Required

String

The name of the range.



Arg3

Optional

Variant

The name of an argument to refine the search.




Return Value
Double
2010 Microsoft Corporation. All rights reserved. (http://www.vbaexpress.com/forum/HV10322970.htm)

lecxe
02-07-2014, 03:29 AM
Hi Valerie

I'm glad it helped.

The help you posted is the help on the Find() method of the WorksheetFunction object.

You should check the help on the Find() method of the Range object. There you can find the options you need for this case.

ValerieT
02-07-2014, 03:50 AM
I just press F1 and it comes automatically... Life is not fare to empiric self learning beginner :-)

Thanks you again and have a nice day

lecxe
02-07-2014, 04:03 AM
You're welcome. Thanks for the feedback.