View Single Post
 
Old 03-15-2022, 07:25 AM
Ulodesk Ulodesk is offline Windows 10 Office 2016
Word 2013 Expert Cert
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Macro for setting decimal tabs in tables

At work we sometimes get pricing tables -- sometimes quite extensive -- in Word that have originated in Excel, in which the numbers are right aligned but by means of a number of preceding spaces. I think these spaces must be an artifact of some conversion process (I can’t imagine anyone creating a giant table in Excel and trying to align the numbers to the right this way), but I'm unable to recreate it. As shown in the attachment, the spaces in Word then push the longer numbers over onto the next line.

My purpose is to try to create a macro that can be applied to the Word table to replace the spaces with a decimal tab that will align the numbers properly. I don't know how to code, but I can record a basic macro. (Thank you for suppressing your mirth.).

Left-aligning the column content I can do, and in the find&replace function with wildcards, ( ){2,} will select the spaces, but I can't find the VBA for a decimal tab to use in the replace field.

Once the tab is "installed", perhaps it can be specified as a distance from the right cell border or inside margin, since table content, layout, and column widths vary. This could then be easily edited if needed.

Help is much appreciated, as always.

(If you know what typically used format in Excel creates these spaces in Word, I'd love to know.)
Attached Files
File Type: docx Numbers.docx (14.5 KB, 9 views)
Reply With Quote