asked on # Word vba code to return the position of the cell I'm in

Hi experts

I suspect this is probably simple, but I have no idea how to do it, or go about it.

I've selected a particular table and I want to find particular text in there. Then I want to go to that text and return the value of the cell I'm in, for example Row(4), Cell(2).

Can someone tell me how to do this.

I suspect this is probably simple, but I have no idea how to do it, or go about it.

I've selected a particular table and I want to find particular text in there. Then I want to go to that text and return the value of the cell I'm in, for example Row(4), Cell(2).

Can someone tell me how to do this.

```
Dim myrange As Range
set myrange = ActiveDocument.Tables(2).Range
myrange.Find.Execute findtext:=texta
If myrange.Find.Found = True Then
'goto that text. What cell am I in?
End If
```

Microsoft WordVisual Basic Classic

View this solution by signing up for a free trial.

Members can start a 7-Day free trial and enjoy unlimited access to the platform.

use :

dim myCell as cell

SET myCell = ActiveDocument.Tables(2).Cell(" & myrange.Cells(1).RowIndex & ", " & myrange.Cells(1).ColumnIndex & ")

myCell.select

dim myCell as cell

SET myCell = ActiveDocument.Tables(2).C

myCell.select

it errors on this line

SET myCell = ActiveDocument.Tables(2).Cell(" & myrange.Cells(1).RowIndex & ", " & myrange.Cells(1).ColumnIndex & ")

SET myCell = ActiveDocument.Tables(2).C

View this solution by signing up for a free trial.

Members can start a 7-Day free trial and enjoy unlimited access to the platform.

Dim myrange As Range

Set myrange = ActiveDocument.Tables(2).Range

myrange.Find.Execute findtext:=texta

If myrange.Find.Found = True Then

myrange.Cells(1).Select

End If

Set myrange = ActiveDocument.Tables(2).R

myrange.Find.Execute findtext:=texta

If myrange.Find.Found = True Then

myrange.Cells(1).Select

End If

That worked - gosh I frustrate myself. Thanks Graham!

Exactly what I was looking for.

As dotoffice has illustrated above, if you only want to select the cell, you don't need to know the address.

Yes, that is a much more simple way of doing what I've ended up doing. Sorry dotoffice I already awarded points. Thanks for your help! I ended up changing what I originally set out to do.

Thank you the message box tells me what cell I need correctly. That's fantastic.

Sorry, novice here, having trouble selecting that cell. Do you know what I'm doing wrong?

Dim myCell as 'I can't get anything to work'

myCell = ActiveDocument.Tables(2).C

myCell.range.Select