View Single Post
 
Old 06-19-2018, 11:29 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you insert a table it will always be on a new 'line'. If you want that table at the end of the cell whether or not it contains text:

Set a range to the cell
Omit the cell end character from the range.
Delete the last empty 'line'

Collapse the range
Insert the table e.g.
Code:
Dim oCell As Range
    Set oCell = Selection.Cells(1).Range
    oCell.End = oCell.End - 1
    If oCell.Characters.Last = Chr(11) Or _
       oCell.Characters.Last = Chr(13) Then
        oCell.Characters.Last.Delete
    End If
    oCell.Collapse 0
    oCell.Tables.Add oCell, 1, 1
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote