Which range contains this table cell?

E

Ed

I have a large table with several named ranges. How can I find which named
range a particular cell is a part of?

Ed
 
J

Jean-Guy Marcil

Ed was telling us:
Ed nous racontait que :
I have a large table with several named ranges. How can I find which
named range a particular cell is a part of?

Named ranges are an Excel thing, but tables are a Word thing... So I will
assume that by Named range you mean a bookmarked area in a Word document. If
part of a table is within a bookmark named "Test", then try this code:

Const BookMarkName As String = "Test"

If Not Selection.Information(wdWithInTable) Then
MsgBox "Selection must be in a table."
Exit Sub
End If

If
Selection.Cells(1).Range.InRange(ActiveDocument.Bookmarks(BookMarkName).Range)
Then
MsgBox "Current cell is in the """ & BookMarkName & """ range."
Else
MsgBox "Current cell is NOT in the """ & BookMarkName & """ range."
End If

If you mean Excel Named range, post again in an Excel group.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
E

Ed

My bust, Jean-Guy!! I am using a Word table, and was **intending** to
create the named ranges, totally forgetting they are only in Excel!

What I am trying to accomplish is to set up groups of cells, and if a
selected cell belongs to such a group, then I will iterate through all the
cells of that group to compare values with the selected cell.

Is there a way to accomplish this in Word VBA? Or would this be easier in
Excel with named ranges?

Ed
 
J

Jean-Guy Marcil

Ed was telling us:
Ed nous racontait que :
My bust, Jean-Guy!! I am using a Word table, and was **intending** to
create the named ranges, totally forgetting they are only in Excel!

What I am trying to accomplish is to set up groups of cells, and if a
selected cell belongs to such a group, then I will iterate through
all the cells of that group to compare values with the selected cell.

Is there a way to accomplish this in Word VBA? Or would this be
easier in Excel with named ranges?

Definitely easier in Excel as Word bookmarks in table do not allow irregular
selection, such as a column.

If you have regular selections to cover (full rows) then you can do it with
bookmarks as in my example.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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

Top