![]() |
Find Method Help in VBA
Hey All,
I need to use the 'Find' method and the documentation doesn't answer a number of questions: -- With the 'LookAt' option, xlWhole or xlPart, whole or part of what? -- Regarding 'What', when it says a Microsoft Excel data type, does that mean integer, long, boolean, etc.? -- For 'SearchFormat', what are the options for this and what do they mean? -- When using 'MatchByte', how does one determine if double-byte support is installed and does it matter if the flag is set (i.e. does it throw an error) if double-byte is support is not installed? expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat) expression Required. An expression that returns a Range object. What Required Variant. The data to search for. Can be a string or any Microsoft Excel data type. After Optional Variant. The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Note that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you don't specify this argument, the search starts after the cell in the upper-left corner of the range. LookIn Optional Variant. The type of information. LookAt Optional Variant. Can be one of the following XlLookAt constants: xlWhole or xlPart. SearchOrder Optional Variant. Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns. SearchDirection Optional XlSearchDirection. The search direction. XlSearchDirection can be one of these XlSearchDirection constants. xlNext default xlPrevious MatchCase Optional Variant. True to make the search case sensitive. The default value is False. MatchByte Optional Variant. Used only if you've selected or installed double-byte language support. True to have double-byte characters match only double-byte characters. False to have double-byte characters match their single-byte equivalents. SearchFormat Optional Variant. The search format. |
Find Method Help in VBA
LookAt - Do you want an exact match or do you want partial matches. For
example in the range you are searching you have a value of Mary-Sue. If you go searching for the value Sue using XLPart it will find Mary-Sue as there is a pratial match. If you were using XLWhole it requires to match the entire string. What - What is a variant meaning that it can take a string or an integer or a double or a ???. It depends on what you are looking for allowing you to search for any type of data. You don't need to worry too much about MatchByte. As it is optional I recommend that you just exclude it. No it should not cause you errors. SearchFormat - True or false depending on whether you want to search for a format such as underlines and such. You need to specify the format with code like this... Application.FindFormat.Borders(xledgebottom).weigh t = xlThick Find returns a range object. That means taht it returns a cell. If no matching cell is found then it returns Nothing. Nothing being a range object that is not set to any cell. Things to note are that you want to specify all of the arguments that are necessary to ensure that it works correctly. Since end users can change the find parameters you can not just leave things to the values that find currently is using. So for example match case is one that you want to specify as you can not guarntee if it is checked or not prior to executing the find. Seach direction on the other hand you may not care about so you can just omit that one... -- HTH... Jim Thomlinson "TC" wrote: Hey All, I need to use the 'Find' method and the documentation doesn't answer a number of questions: -- With the 'LookAt' option, xlWhole or xlPart, whole or part of what? -- Regarding 'What', when it says a Microsoft Excel data type, does that mean integer, long, boolean, etc.? -- For 'SearchFormat', what are the options for this and what do they mean? -- When using 'MatchByte', how does one determine if double-byte support is installed and does it matter if the flag is set (i.e. does it throw an error) if double-byte is support is not installed? expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat) expression Required. An expression that returns a Range object. What Required Variant. The data to search for. Can be a string or any Microsoft Excel data type. After Optional Variant. The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Note that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you don't specify this argument, the search starts after the cell in the upper-left corner of the range. LookIn Optional Variant. The type of information. LookAt Optional Variant. Can be one of the following XlLookAt constants: xlWhole or xlPart. SearchOrder Optional Variant. Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns. SearchDirection Optional XlSearchDirection. The search direction. XlSearchDirection can be one of these XlSearchDirection constants. xlNext default xlPrevious MatchCase Optional Variant. True to make the search case sensitive. The default value is False. MatchByte Optional Variant. Used only if you've selected or installed double-byte language support. True to have double-byte characters match only double-byte characters. False to have double-byte characters match their single-byte equivalents. SearchFormat Optional Variant. The search format. |
Find Method Help in VBA
#1. LookAt:=xlwhole means that the thing you're looking for must match the
value in the cell (exactly). So if the cell contained "TC Wrote", then looking for TC (and xlwhole) would mean that this cell wouldn't be a match. lookat:=xlpart means that you don't have to match the whole cell (but you can). Looking for TC (and xlpart) would find it in "TC Wrote", "this is what TC wrote", or even exactly "TC". (This is not the the same thing as MSWord's "Find Whole Words Only"--excel doesn't have this kind of thing.) #2. Yep. But it has to be something that resolves to a simple value--No objects (object.value and object.text are ok), no arrays (an element of the array could be ok, though.) #3. Do an Edit|Find in excel. Click on the Options button if you can't see the options. You'll see you can specify the format of what you want to find. If you record a macro when you do it manually, you'll see what the code looks like. #4. I don't have doublebyte stuff is installed. I think that stuff is for unicode characters--like some languages (Chinese???)--but that's a guess. =========== Ps. One thing to remember is that these settings are shared between your code and the user. So it's always a good idea to specify what you want -- else you may be inheriting the settings from the previous find (by the user or by someone else's code!). TC wrote: Hey All, I need to use the 'Find' method and the documentation doesn't answer a number of questions: -- With the 'LookAt' option, xlWhole or xlPart, whole or part of what? -- Regarding 'What', when it says a Microsoft Excel data type, does that mean integer, long, boolean, etc.? -- For 'SearchFormat', what are the options for this and what do they mean? -- When using 'MatchByte', how does one determine if double-byte support is installed and does it matter if the flag is set (i.e. does it throw an error) if double-byte is support is not installed? expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat) expression Required. An expression that returns a Range object. What Required Variant. The data to search for. Can be a string or any Microsoft Excel data type. After Optional Variant. The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Note that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you don't specify this argument, the search starts after the cell in the upper-left corner of the range. LookIn Optional Variant. The type of information. LookAt Optional Variant. Can be one of the following XlLookAt constants: xlWhole or xlPart. SearchOrder Optional Variant. Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns. SearchDirection Optional XlSearchDirection. The search direction. XlSearchDirection can be one of these XlSearchDirection constants. xlNext default xlPrevious MatchCase Optional Variant. True to make the search case sensitive. The default value is False. MatchByte Optional Variant. Used only if you've selected or installed double-byte language support. True to have double-byte characters match only double-byte characters. False to have double-byte characters match their single-byte equivalents. SearchFormat Optional Variant. The search format. -- Dave Peterson |
Find Method Help in VBA
Thanks guys!
"TC" wrote in message ... Hey All, I need to use the 'Find' method and the documentation doesn't answer a number of questions: -- With the 'LookAt' option, xlWhole or xlPart, whole or part of what? -- Regarding 'What', when it says a Microsoft Excel data type, does that mean integer, long, boolean, etc.? -- For 'SearchFormat', what are the options for this and what do they mean? -- When using 'MatchByte', how does one determine if double-byte support is installed and does it matter if the flag is set (i.e. does it throw an error) if double-byte is support is not installed? expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat) expression Required. An expression that returns a Range object. What Required Variant. The data to search for. Can be a string or any Microsoft Excel data type. After Optional Variant. The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Note that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you don't specify this argument, the search starts after the cell in the upper-left corner of the range. LookIn Optional Variant. The type of information. LookAt Optional Variant. Can be one of the following XlLookAt constants: xlWhole or xlPart. SearchOrder Optional Variant. Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns. SearchDirection Optional XlSearchDirection. The search direction. XlSearchDirection can be one of these XlSearchDirection constants. xlNext default xlPrevious MatchCase Optional Variant. True to make the search case sensitive. The default value is False. MatchByte Optional Variant. Used only if you've selected or installed double-byte language support. True to have double-byte characters match only double-byte characters. False to have double-byte characters match their single-byte equivalents. SearchFormat Optional Variant. The search format. |
Thanks guys!
thats all well when you are talking about a cell but what about a whold module of code
VBIDE.CODEMODULE.object.Find(target, startline, startcol, endline, endcol [, wholeword] [, matchcase] [, patternsearch]) As Boolean Module I am searching contains the line wwEmail.SendSMTPMail objModuleOfCode.Find("wwEmail.", SL, SC, EL, EC, True, False, False) Finds nothing (ie = False) the optional wholeword parameter to "False" and it finds it Now unless the 2 functions are different from this we can see are actually talking about matching a wholewordinthetexttobesearched with the whole of the texttobefound OR partofawholewordinthetexttobesearched with the whole of the texttobefound Cheers On Thursday, September 04, 2008 5:11 PM TC wrote: Hey All, I need to use the 'Find' method and the documentation doesn't answer a number of questions: -- With the 'LookAt' option, xlWhole or xlPart, whole or part of what? -- Regarding 'What', when it says a Microsoft Excel data type, does that mean integer, long, boolean, etc.? -- For 'SearchFormat', what are the options for this and what do they mean? -- When using 'MatchByte', how does one determine if double-byte support is installed and does it matter if the flag is set (i.e. does it throw an error) if double-byte is support is not installed? expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat) expression Required. An expression that returns a Range object. What Required Variant. The data to search for. Can be a string or any Microsoft Excel data type. After Optional Variant. The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Note that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you don't specify this argument, the search starts after the cell in the upper-left corner of the range. LookIn Optional Variant. The type of information. LookAt Optional Variant. Can be one of the following XlLookAt constants: xlWhole or xlPart. SearchOrder Optional Variant. Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns. SearchDirection Optional XlSearchDirection. The search direction. XlSearchDirection can be one of these XlSearchDirection constants. xlNext default xlPrevious MatchCase Optional Variant. True to make the search case sensitive. The default value is False. MatchByte Optional Variant. Used only if you've selected or installed double-byte language support. True to have double-byte characters match only double-byte characters. False to have double-byte characters match their single-byte equivalents. SearchFormat Optional Variant. The search format. On Thursday, September 04, 2008 6:10 PM James_Thomlinso wrote: LookAt - Do you want an exact match or do you want partial matches. For example in the range you are searching you have a value of Mary-Sue. If you go searching for the value Sue using XLPart it will find Mary-Sue as there is a pratial match. If you were using XLWhole it requires to match the entire string. What - What is a variant meaning that it can take a string or an integer or a double or a ???. It depends on what you are looking for allowing you to search for any type of data. You don't need to worry too much about MatchByte. As it is optional I recommend that you just exclude it. No it should not cause you errors. SearchFormat - True or false depending on whether you want to search for a format such as underlines and such. You need to specify the format with code like this... Application.FindFormat.Borders(xledgebottom).weigh t = xlThick Find returns a range object. That means taht it returns a cell. If no matching cell is found then it returns Nothing. Nothing being a range object that is not set to any cell. Things to note are that you want to specify all of the arguments that are necessary to ensure that it works correctly. Since end users can change the find parameters you can not just leave things to the values that find currently is using. So for example match case is one that you want to specify as you can not guarntee if it is checked or not prior to executing the find. Seach direction on the other hand you may not care about so you can just omit that one... -- HTH... Jim Thomlinson "TC" wrote: On Thursday, September 04, 2008 6:12 PM Dave Peterson wrote: value in the cell (exactly). So if the cell contained "TC Wrote", then looking for TC (and xlwhole) would mean that this cell wouldn't be a match. lookat:=xlpart means that you don't have to match the whole cell (but you can). Looking for TC (and xlpart) would find it in "TC Wrote", "this is what TC wrote", or even exactly "TC". (This is not the the same thing as MSWord's "Find Whole Words Only"--excel doesn't have this kind of thing.) objects (object.value and object.text are ok), no arrays (an element of the array could be ok, though.) options. You'll see you can specify the format of what you want to find. If you record a macro when you do it manually, you'll see what the code looks like. unicode characters--like some languages (Chinese???)--but that's a guess. =========== Ps. One thing to remember is that these settings are shared between your code and the user. So it's always a good idea to specify what you want -- else you may be inheriting the settings from the previous find (by the user or by someone else's code!). TC wrote: -- Dave Peterson On Thursday, September 04, 2008 7:17 PM TC wrote: Thanks guys! |
All times are GMT +1. The time now is 07:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com