#1
|
|||
|
|||
How to remove the last comma at the end of a table entry
I am using MergeFields to pull information from a database into a Microsoft Word table. If there is nothing in the last field, it still inserts the comma - with nothing after. I need to find a way to remove the last comma if there are no words following it. I cannot use a Replace, because there are other commas that need to stay. Here is an example:
"24 Volt D.C Flashing Light With Built-in Antenna 433Mhz, DEA+ Product Guide", Meteor electrical, meteorelectrical.com, Code: LUMY/24A, 07/28/2010, These merges are 250+ pages long, so I would love to find a way to delete these "last" commas without going through line by line. Thank you! |
#2
|
||||
|
||||
Quote:
Find = ,^p Replace = ^p Better still, since this is for a mailmerge, you should consider using the mergefield \b switch in the last mergefield in the mailmerge main document and omitting the preceding comma. For example: {MERGEFIELD Item \b ", "} where 'Item' is the mergefield name.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
No luck with the replacing method...it must not be a paragraph break separating the cells. I can't modify the mergefield because the report isn't mine (it was created by the database I'm using).
Any other ideas? Thank you so much for your help! |
#4
|
||||
|
||||
In that case, you'll probably need a macro like:
Code:
Sub CommaCleanUp() Dim Tbl As Table, Cll As Cell Application.ScreenUpdating = False For Each Tbl In ActiveDocument.Tables For Each Cll In Tbl.Range.Cells With Cll.Range If Len(.Text) > 2 Then Do While .Characters.Last.Previous = "," .Characters.Last.Previous.Delete Loop End If End With Next Next Application.ScreenUpdating = True End Sub For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to remove auto type entry | ep2002 | Excel | 19 | 11-06-2013 08:48 AM |
Trying to update a table cell with a value based on a drop down box entry | mkasem | Word VBA | 2 | 09-29-2013 08:36 PM |
Remove Paragraph numbers from Table of Co | Bu_zz2020 | Word | 3 | 08-27-2013 08:49 AM |
Remove space after table in header | melliejane | Word | 1 | 03-05-2012 04:09 PM |
How to remove "Table of Figures" as we do to remove the "Table of Contents"? | Jamal NUMAN | Word | 1 | 07-08-2011 05:40 PM |