Ed
Tue Dec 13 13:37:43 CST 2005
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
"Jean-Guy Marcil" <NoSpam@LeaveMeAlone> wrote in message
news:%23DhtmfBAGHA.4012@TK2MSFTNGP10.phx.gbl...
> 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).Rang
e)
> 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
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site:
http://www.word.mvps.org
>
>