Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Function that emulates FIND(find_text,within_text,start_num)

Hi,

I would like to write a function FINDC that emulated
Excel's FIND worksheet function but returns '0' rather
than #VALUE! if find_text does not appear in within_text.

Is it possible, by the way, to see the source code for
excel functions in Visual Basic?

Thanks,
Henrik
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Function that emulates FIND(find_text,within_text,start_num)

Excel functions aren't written in visual basic, but the short answer is no.

Public Function FindC(sStr As String, _
sStr1 As String, Optional iloc As Long = 1)
FindC = InStr(iloc, sStr1, sStr, vbTextBinary)
End Function

Lightly tested.

--
Regards,
Tom Ogilvy



"Henrik" wrote in message
...
Hi,

I would like to write a function FINDC that emulated
Excel's FIND worksheet function but returns '0' rather
than #VALUE! if find_text does not appear in within_text.

Is it possible, by the way, to see the source code for
excel functions in Visual Basic?

Thanks,
Henrik



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Function that emulates FIND(find_text,within_text,start_num)

Hi Henrik,

Alternatively, you could use the actual FIND worksheet function and trap the
error that occurs when it fails:

Public Function FINDC(find_text As String, within_text As String, _
Optional start_num As Integer = 1) As Integer
On Error Resume Next
FINDC = Application.WorksheetFunction.Find(find_text, _
within_text, start_num)
End Function

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Henrik wrote:
Hi,

I would like to write a function FINDC that emulated
Excel's FIND worksheet function but returns '0' rather
than #VALUE! if find_text does not appear in within_text.

Is it possible, by the way, to see the source code for
excel functions in Visual Basic?

Thanks,
Henrik


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Function that emulates FIND(find_text,within_text,start_num)

The actual constant (vbTextBinary) is incorrect, but doesn't affect
operation because it resolves to zero which is correct - but to be accurate
here is a revision. The constant should be vbBinaryCompare

Public Function FindC(sStr As String, _
sStr1 As String, Optional iloc As Long = 1)
FindC = InStr(iloc, sStr1, sStr, vbBinaryCompare)
End Function

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Excel functions aren't written in visual basic, but the short answer is

no.

Public Function FindC(sStr As String, _
sStr1 As String, Optional iloc As Long = 1)
FindC = InStr(iloc, sStr1, sStr, vbTextBinary)
End Function

Lightly tested.

--
Regards,
Tom Ogilvy



"Henrik" wrote in message
...
Hi,

I would like to write a function FINDC that emulated
Excel's FIND worksheet function but returns '0' rather
than #VALUE! if find_text does not appear in within_text.

Is it possible, by the way, to see the source code for
excel functions in Visual Basic?

Thanks,
Henrik





Reply
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
Trying to find which function to use J4shaw Excel Worksheet Functions 3 August 3rd 09 05:58 AM
Find Function VickiMc Excel Worksheet Functions 1 February 12th 09 02:31 AM
SEARCH(find_text,within_text,start_num) dangerd Excel Discussion (Misc queries) 3 October 30th 07 06:46 PM
Find function alamo Excel Worksheet Functions 1 September 16th 05 02:01 PM
Help with the FIND function Ranger Excel Worksheet Functions 1 February 25th 05 03:24 PM


All times are GMT +1. The time now is 02:49 PM.

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"