#1   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Function

I have this function below, it's purpose is to search text from a list on
Sheets("Input_Data") and return the text. Can you please modify the code to
select the range of the of the list when using the function.


Dim excelapp As Excel.Application
Dim excelWb As Excel.Workbook
Dim excelSheet As Excel.Worksheet

Function SearchTxt(MyText As String, Text_Length As Integer, Search_Guess As
Integer) As String

'MyText is the cell you want to search.
'Text_Length allows you to vary the length of the text returned
'Search_Guess can be used if you want to start the search at a particular
point in the cell

Dim intI As Integer
Dim SearchItem(100) As String
Dim LenText As Integer
Dim n2 As Integer
Dim n As Integer
Dim Mk1 As Integer

' Initialise array with values from column A of Input_Data work sheet -
allows 100 different codes
For intI = 1 To 100
SearchItem(intI) = Sheets("Input_Data").Cells([intI], [1])
Next

LenText = Len(MyText)

For n2 = 1 To 100 Step 1


For n = Search_Guess To LenText Step 1
If Mid(MyText, n, Text_Length) = SearchItem(n2) Then
Mk1 = n
End If
Next n

Next

SearchRL = Mid(MyText, Mk1, Text_Length)
MyEndBit:
End Function
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
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
copy of excel file not showing formulal/function in the function b oaallam Excel Discussion (Misc queries) 4 September 6th 07 01:20 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Emulate Index/Match combo function w/ VBA custom function Spencer Hutton Excel Worksheet Functions 2 May 2nd 05 05:26 PM


All times are GMT +1. The time now is 08:47 AM.

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

About Us

"It's about Microsoft Excel"