View Single Post
 
Old 10-21-2025, 03:08 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,178
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Another non-optimal method is to use the selection object. It has the benefit of working across page breaks.
Code:
Sub HowManyLines()
  Dim aRng As Range, i As Integer, aTbl As Table
  Set aTbl = ActiveDocument.Tables(1)
  Set aRng = aTbl.Cell(1, 2).Range
  aRng.Select
  Selection.Collapse Direction:=wdCollapseStart
  Do While Selection.Range.End < aRng.End
    i = i + 1
    Selection.MoveDown Unit:=wdLine, Count:=1
  Loop
  MsgBox "Cell line count: " & i
End Sub
The problem with this method is that it relies on moving the selection. I wasn't able to find a Range.MoveDown option but if one existed then it would be better than using Selection.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia

Last edited by Guessed; 10-21-2025 at 03:11 PM. Reason: Modified to use Table.Cell(r,c) as OP requested
Reply With Quote