Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-02-2016, 06:35 AM
lmvantassel lmvantassel is offline How to remove the last comma at the end of a table entry Windows 10 How to remove the last comma at the end of a table entry Office 2013
Novice
How to remove the last comma at the end of a table entry
 
Join Date: Nov 2016
Posts: 2
lmvantassel is on a distinguished road
Default 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!
Reply With Quote
  #2  
Old 11-02-2016, 03:58 PM
macropod's Avatar
macropod macropod is offline How to remove the last comma at the end of a table entry Windows 7 64bit How to remove the last comma at the end of a table entry Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by lmvantassel View Post
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.
Assuming each line is terminated by a paragraph break, you could use Find/Replace, with:
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]
Reply With Quote
  #3  
Old 11-03-2016, 11:17 AM
lmvantassel lmvantassel is offline How to remove the last comma at the end of a table entry Windows 10 How to remove the last comma at the end of a table entry Office 2013
Novice
How to remove the last comma at the end of a table entry
 
Join Date: Nov 2016
Posts: 2
lmvantassel is on a distinguished road
Default

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!
Reply With Quote
  #4  
Old 11-03-2016, 12:53 PM
macropod's Avatar
macropod macropod is offline How to remove the last comma at the end of a table entry Windows 7 64bit How to remove the last comma at the end of a table entry Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

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 PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove auto type entry ep2002 Excel 19 11-06-2013 08:48 AM
How to remove the last comma at the end of a table entry 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
How to remove the last comma at the end of a table entry Remove space after table in header melliejane Word 1 03-05-2012 04:09 PM
How to remove the last comma at the end of a table entry 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:11 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