LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Need help utilizing the "Like" function

Function AllDigits(s)
AllDigits = s Like String(Len(s), "#")
End Function


Thanks Rick. I totally forgot about that. :~
Thanks for the catch.

Dana DeLouis



On 2/10/2010 11:01 PM, Rick Rothstein wrote:
Function AllDigits(s)
AllDigits = s Like WorksheetFunction.Rept("[0-9]", Len(s))
End Function


Noting that you can use the # sign in place of [0-9] when searching for
digits, you do not have to call out to the Worksheet to use its REPT
function... VB has the String function that you can use instead.

Function AllDigits(s)
AllDigits = s Like String(Len(s), "#")
End Function

If, however, you are more used to using [0-9] instead of the # sign and
want to continue doing so, you can still do this using native VB
functions only...

Function AllDigits(s)
AllDigits = s Like Replace(String(Len(s), "x"), "x", "[0-9]")
End Function

where you can use any character in place of the "x" characters I used.
Because of this, we can simplify this code by using a space instead of
the "x" and then noting that VB has a Space function which returns the
number of space specified in its argument...

Function AllDigits(s)
AllDigits = s Like Replace(Space(Len(s)), " ", "[0-9]")
End Function



--
= = = = = = =
HTH :)
Dana DeLouis
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel 2003: Conditional Formatting using "MIN" & "MAX" function MMangen Excel Discussion (Misc queries) 2 September 16th 08 07:13 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
function to return day in the form "Monday", "Tuesday" etc given . MTro Excel Worksheet Functions 2 October 3rd 07 09:49 AM
Please add a "sheet" function like "row" and "column" functions Spreadsheet Monkey Excel Programming 2 November 8th 05 04:08 PM


All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"