Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Find method to find cell row

Status
Not open for further replies.

philrock

Programmer
Jan 29, 2004
109
US
I'm very much a noob at VBA for Excel. I'm trying to write a function that will return the row number of a cell where certain data is located. In the code below, the data is all located in column B, and I'm trying to find the row number of the cell containing the string "d1".

Function d1row()
d1row = Range("B:B").Find(What:="d1", _
After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Row
End Function

All I get is the #VALUE! error in the worksheet cell where I enter the function. I've tried many variations on the Find parameters, but always the same result.

What am I doing wrong?
 
macropod,

Thanks very much for your help with this - you've been more than patient.

philrock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top