View Single Post
 
Old 07-11-2015, 09:29 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,902
macropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud of
Default Identifying Table Cell Addresses

Word supports tables with up to 63 columns and an apparently unlimited rows (provided you keep within the 32Mb document text limit). Unlike Excel, however, Word doesn’t automatically indicate which cell your cursor is in. This can be difficult to work out in a large table, especially when you start working with merged cells. The following macro outputs the address of the table's selected cell range and the table’s last cell address on Word’s Status Bar:
Code:
Sub CellRange()
Dim StrAddr As String
' This macro displays the address of a table's selected cell range
' and the table’s last cell address on Word's Status Bar
With Selection
  If .Information(wdWithInTable) = True Then
    StrAddr = "The selected "
    If .Cells.Count = 1 Then
      StrAddr = StrAddr & "cell address is: "
    Else
      StrAddr = StrAddr & "cells span: "
    End If
    StrAddr = StrAddr & ColAddr(.Cells(1).ColumnIndex) & .Cells(1).RowIndex
    If .Cells.Count > 1 Then
      StrAddr = StrAddr & ":" & ColAddr(.Characters.Last.Cells(1).ColumnIndex) & _
        .Characters.Last.Cells(1).RowIndex
    End If
    With .Tables(1).Range
    StrAddr = StrAddr & ". The table's last cell is at: " & _
      ColAddr(.Cells(.Cells.Count).ColumnIndex) & .Cells(.Cells.Count).RowIndex
    End With
      StatusBar = StrAddr
    Else
      StatusBar = "The selection is not in a table!"
  End If
End With
End Sub
 
Function ColAddr(i As Long) As String
If i > 26 Then
  ColAddr = Chr(64 + Int(i / 26)) & Chr(64 + (i Mod 26))
Else
  ColAddr = Chr(64 + i)
End If
End Function
If you prefer the output to appear in a message box instead of in the status bar, change:
Code:
    StrAddr = StrAddr & ". The table's last cell is at: " & _
      ColAddr(.Cells(.Cells.Count).ColumnIndex) & .Cells(.Cells.Count).RowIndex
    End With
      StatusBar = StrAddr
    Else
      StatusBar = "The selection is not in a table!"
  End If
to:
Code:
    StrAddr = StrAddr & vbCr & "The table's last cell is at: " & _
      ColAddr(.Cells(.Cells.Count).ColumnIndex) & .Cells(.Cells.Count).RowIndex
    End With
      MsgBox StrAddr, vbOKOnly
    Else
      MsgBox "The selection is not in a table.", vbExclamation
  End If
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm.
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]