memorize cells position

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
My question is simply enough, but searching in the previous posts I didn't
find any similar one.
So, in my excel sheet after looking for a string with this command:

Cells.Find(What:="REPORT DATE", LookIn:=xlFormulas, LookAt:=xlPart).Activate

I need to put into a variable the first coordinate of row and column that
satisfy my find criteria.
Thanks in advance.
 
Hi Andrea,

Try something like:

'=============>>
Public Sub Tester001()
Dim SH As Worksheet
Dim Rng As Range
Dim sAdd As String
Dim iRow As Long
Dim iCol As Long

Set SH = ActiveSheet '<<==== CHANGE
With SH
Set Rng = .Cells.Find(What:="REPORT DATE", _
After:=.Cells(1), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With

If Not Rng Is Nothing Then
With Rng
sAdd = .Address(0, 0)
iRow = .Row
iCol = .Column
End With
End If
End Sub
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top