Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Howdee all.
Has anyone ever made a UDF, for Like, to use in a worksheet function? I.e., look at a string of text in a cell, and see if a given format exists, to then perform a worksheet operation on that cell's contents, based on its matching the like operator? I swear I remember a discussion like this before, but I can't find it. I am aware that it's not a standard worksheet function. Hence the UDF. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You cannot perform a worksheet operation on a cell from within a function,
with or without Like. -- HTH Bob "Steve" wrote in message ... Howdee all. Has anyone ever made a UDF, for Like, to use in a worksheet function? I.e., look at a string of text in a cell, and see if a given format exists, to then perform a worksheet operation on that cell's contents, based on its matching the like operator? I swear I remember a discussion like this before, but I can't find it. I am aware that it's not a standard worksheet function. Hence the UDF. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It should be as simple as this...
Function IsLike(TextString As String, Pattern As String) As Boolean IsLike = TextString Like Pattern End Function Note that you can't call the function "Like" because that is a reserved function name in VB, so you can't name a VB function that; hence, I chose to call it IsLike. You can use any Like patterns for the Pattern argument. -- Rick (MVP - Excel) "Steve" wrote in message ... Howdee all. Has anyone ever made a UDF, for Like, to use in a worksheet function? I.e., look at a string of text in a cell, and see if a given format exists, to then perform a worksheet operation on that cell's contents, based on its matching the like operator? I swear I remember a discussion like this before, but I can't find it. I am aware that it's not a standard worksheet function. Hence the UDF. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Of course Bob is right... you cannot perform "worksheet operations" as such,
but my IsLike function can do whatever a normal worksheet function can do. So, you could do, say, this... =IF(IsLike(A1,"###"),"A1 has exactly 3 digits", "Wrong number of digits") You can also use the IsLike function in a Conditional Format in order to, say, change the cell color if the contents of the cell meets (or doesn't meet) a certain pattern. -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... It should be as simple as this... Function IsLike(TextString As String, Pattern As String) As Boolean IsLike = TextString Like Pattern End Function Note that you can't call the function "Like" because that is a reserved function name in VB, so you can't name a VB function that; hence, I chose to call it IsLike. You can use any Like patterns for the Pattern argument. -- Rick (MVP - Excel) "Steve" wrote in message ... Howdee all. Has anyone ever made a UDF, for Like, to use in a worksheet function? I.e., look at a string of text in a cell, and see if a given format exists, to then perform a worksheet operation on that cell's contents, based on its matching the like operator? I swear I remember a discussion like this before, but I can't find it. I am aware that it's not a standard worksheet function. Hence the UDF. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
automatically appending newly added data on worksheet to a master list worksheet | Links and Linking in Excel | |||
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 | Excel Worksheet Functions | |||
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet | Excel Worksheet Functions | |||
I want in one worksheet to relatively link to/reference cells in another without changing the format of the current worksheet. | Excel Discussion (Misc queries) | |||
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet | Excel Programming |