Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 07-11-2015, 09:29 PM
macropod's Avatar
macropod macropod is offline Identifying Table Cell Addresses Windows 7 64bit Identifying Table Cell Addresses Office 2010 32bit
Administrator
Identifying Table Cell Addresses
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
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()
'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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying Table Cell Addresses Move table cell contents from one table to another table or cell in same table donaldadams1951 Word VBA 4 02-04-2015 03:54 PM
Identifying Table Cell Addresses Table with text that flows from cell to cell hwrigley Word Tables 7 02-18-2014 02:59 AM
Identifying Table Cell Addresses Identifying Postcodes. Chayes Word VBA 13 09-21-2013 06:29 AM
Auto-populate an MS Word table cell with text from a diff cell? dreamrthts Word Tables 0 03-20-2009 01:49 PM
Identifying the Dynamic Connector cyberbhai Misc 0 12-14-2005 03:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft