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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

range.Find method - found address in r, c format as opposed to "A4" , say

Status
Not open for further replies.

h4fod

Technical User
Jan 10, 2011
42
GB
Hi
I am prototyping VBA code to use in a wider app that I am building using Excel 2003. Trying to understand Find / findnext methods etc. However, with code below, how can I obtain the address in row, col format rather than traditional "A3" format for example in aCell.Address?
many thanks in anticipation.

CODE
Dim strSearch As String
Dim aCell As Range
Dim oSht As Worksheet

On Error GoTo Err

Set oSht = Sheets("All")

'lastRow = oSht.Range("A" & Rows.Count).End(xlUp).Row
LastCol = oSht.Range("A1:H1").End(xlUp).Column

strSearch = "In LEA care"

Set aCell = oSht.Range("A1:H1").Find(What:=strSearch, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If Not aCell Is Nothing Then
MsgBox "Value Found in Cell " & aCell.Address


End If

Exit Sub
Err:
MsgBox Err.Description
/CODE

 
Like this ?
MsgBox "Value Found in Cell at Row " & aCell.Row & ", Col " & aCell.Column

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi
Many thanks for your post which addresses my query exactly.
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top