LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,comp.apps.spreadsheets,microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Problems with SearchInRange() macro

MS Excel 97 SR-2

Having problems with the implementation for

SearchInRange(AS13,'\Obsolescence\[obsolete-list.xls]A'!$C1:$C10,1,1)

1) Can't get the search() worksheet function to work in the macro
2) Debugger has quit on me.

Point 2 first: I have had an excel crash, tried to change the name of
a watch variable by editing it. Since restarting Excel, the VBA
debugger does not respect my breakpoints in SearchInRange(). Am
loathe to restart the PC - is there a reason for this, and more
importantly, a workaround?

Point 1: I cannot step over a line of the form

result = searchRange(1, 1).Value

This is the function prototype :

Public Function SearchInRange(searchStr, searchRange As Range,
cellPos, strPos)

VBA seems to perform a number of iterations on the "result =" line,
then when it returns the value of all watch variables are "Out of
context" (or whatever the message is, the debugger is now not
restarting).

Here is the full macro code (for the debug version, the obvious
reverse changes are performed to return it to "as-designed" :

' --------- Debug version
'
' Range equivalent to Search("M","Miriam McGovern",3) equals 8
' Search() is case insensitive, ? and * wildcard version of Find()
'
Public Function SearchInRange(searchStr, searchRange As Range,
cellPos, strPos)
SearchInRange = "SYNTAX : SearchInRange(searchStr, searchRange as
Range, cellPos, strPos)"
'
Dim result As Integer, iCell As Integer, notFound As Integer
If searchRange.Areas.Count = 1 Then
iCell = cellPos
notFound = 1
' While (iCell <= searchRange.Count & notFound)
iCell = 3
result = searchRange(1, 1).Value
result = searchRange(iCell, 1).Value
result = Application.Search(searchStr, result, strPos)
notFound = Application.IsError(result)
iCell = iCell + 1
' Wend
If (notFound) Then
SearchInRange = 0
Else
SearchInRange = iCell - 1
End If
End If
End Function
 
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
Macro problems Father John Excel Discussion (Misc queries) 3 April 20th 10 11:24 PM
Macro Problems laxnation87 Excel Discussion (Misc queries) 1 August 7th 07 05:41 PM
Macro problems Heine Excel Worksheet Functions 9 October 31st 06 11:01 AM
Macro problems Retta Excel Worksheet Functions 2 May 18th 05 10:39 PM
macro problems Peter Wiley Excel Programming 2 September 10th 03 09:53 PM


All times are GMT +1. The time now is 04:21 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"