![]() |
#1
|
|||
|
|||
![]()
I've tried researching on Google on how to find the last cell in a column of a Word table but have been unable to find anything.
When I run my TextToTable code, I would like to change the semi colon in the very last cell of Column 2 to a period/full stop but unsure how to add this to my existing code. Can anyone help at all? Capture.JPG Code:
Sub TextToTables() Dim rRng As Range, rCell As Range 'Convert text to table Dim oBorder As Border Dim oTbl As Table Dim i As Integer Application.ScreenUpdating = False Set rRng = ActiveDocument.Range Set oTbl = rRng.ConvertToTable(Separator:=wdSeparateByTabs, NumColumns:=2, AutoFitBehavior:=wdAutoFitFixed) With oTbl .Style = "Table Grid" .ApplyStyleHeadingRows = True .ApplyStyleLastRow = False .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = False .Columns.PreferredWidth = InchesToPoints(2.7) .Columns(2).PreferredWidth = InchesToPoints(3.63) For Each oBorder In .Borders oBorder.LineStyle = wdLineStyleNone Next oBorder Call DPU_ApplyDefinitionStylesToTable For i = 1 To .Rows.count 'check each row Set rCell = .Cell(i, 1).Range 'set a range to the cells in column 1 rCell.Style = "DefBold" 'apply the style to the range Set rCell = .Cell(i, 2).Range 'set a range to the cells in column 2 rCell.Collapse 1 'collapse the range to its start rCell.MoveEndWhile "means,:" 'move the end of the range to include any of these characters If rCell.text Like "means*" Then 'if that range starts with 'means' rCell.MoveEndWhile Chr(32) 'move the end of the range to include any following spaces rCell.text = "" 'and empty the range End If Next i End With Application.ScreenUpdating = True Set rRng = Nothing Set oTbl = Nothing Set rCell = Nothing Set oBorder = Nothing End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
EddyWD | Excel | 3 | 04-20-2016 09:29 PM |
VBA Word - Find Specific Table - Prepend & Append Data to Each Cell | jc491 | Word VBA | 3 | 12-02-2015 09:48 PM |
![]() |
jc491 | Word VBA | 8 | 09-30-2015 06:10 AM |
Find text within cell and return column and row title next to the name on a new sheet. | tanyabowring@live.co.uk | Excel Programming | 2 | 03-26-2015 01:48 AM |
How do I reference a merged cell in a multi column & row table in MS Word ('03')? | jihanemo | Word Tables | 0 | 03-18-2009 08:33 AM |