LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Find Method within a called procedure

With VBA, I've had success building loops to find a cell using
cells(row,col) within row and column loops. I copied the
cells.find code below from recording the menu Edit Find
function to try and let Excel do the "looping" work via
the zString_Find called sub.

I'm trying for row and col to have 0 values when
a cell is found in the a__test procedure.

I've tried a couple of variations without success.
two problems:
1) when I find a cell, the msgbox shows row and column values
of 0

2) when the value is not found, I'm getting a run time 91
error, object variable or with block variable not set.
I can't seem to find the right method to not error out
when the value I'm looking for is not found.

Help please.
Thanks,
Neal



Sub a__TEST()
Dim Chars As String, Row As Integer, Col As Integer
Chars = "zzzzend"
Call zString_Find(Chars, Row, Col)
MsgBox "Found row,col " & Row & ", " & Col, , "Find this: " & Chars
End Sub


Sub zString_Find(IFindTheseChars, ORow, OCol)
' I var names are input, O vars are output
Range("a1").Activate
ORow = 0: OCol = 0
Application.DisplayAlerts = False

Cells.Find(What:=IFindTheseChars, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

If ActiveCell.Row < 1 And ActiveCell.Column < 1 Then
ORow = ActiveCell.Row
OCol = ActiveCell.Column
End If

Application.DisplayAlerts = True
End Sub
--
Neal Z
 
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
How can Oracle DB Stored procedure be called in MS Excel? Amol Excel Discussion (Misc queries) 1 January 7th 07 10:05 AM
procedure continuously being called nathan Excel Programming 9 January 19th 06 08:40 PM
private sub- which procedure called it Sunil Excel Programming 2 September 27th 05 12:52 PM
range.find method called into a VBA function (problem) Eros Pedrini Excel Programming 5 November 17th 04 12:34 PM
Opening a UserForm causes a crash in the Exit procedure (Which is never called) Brent McIntyre Excel Programming 0 May 12th 04 12:37 PM


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