Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can Oracle DB Stored procedure be called in MS Excel? | Excel Discussion (Misc queries) | |||
procedure continuously being called | Excel Programming | |||
private sub- which procedure called it | Excel Programming | |||
range.find method called into a VBA function (problem) | Excel Programming | |||
Opening a UserForm causes a crash in the Exit procedure (Which is never called) | Excel Programming |