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()
'Sourced from: https://www.msofficeforums.com/word-tables/26997-identifying-table-cell-addresses.html
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:
Installing Macros.
For Mac macro installation & usage instructions, see:
Word:mac - Install a Macro.