Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-15-2022, 12:21 PM
Ulodesk Ulodesk is offline Macro for setting decimal tabs in tables Windows 10 Macro for setting decimal tabs in tables Office 2016
Word 2013 Expert Cert
Macro for setting decimal tabs in tables
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default

Thank you very much, Graham. Pigs would fly before I figured that one out on my own.



May I ask, what does the "Position:=InchesToPoints(1.41), " instruct?

Thanks again!
Reply With Quote
  #2  
Old 03-15-2022, 09:47 PM
gmayor's Avatar
gmayor gmayor is offline Macro for setting decimal tabs in tables Windows 10 Macro for setting decimal tabs in tables Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

Quote:
Originally Posted by Ulodesk View Post
May I ask, what does the "Position:=InchesToPoints(1.41), " instruct?
It sets the position of the decimal tab in the cell, however on returning to the question, I note that the column widths may be variable, in which case the following may work better.
Code:
Sub Macro1()
Dim oTable As Table
Dim i As Integer
Dim oCell As Cell
Dim oRng As Range
Dim iPos As Integer
    Set oTable = Selection.Tables(1)
    With oTable
        For i = 2 To .Rows.Count
            For Each oCell In .Rows(i).Cells
                iPos = oCell.Width - oCell.LeftPadding - oCell.RightPadding - 20
                Set oRng = oCell.Range
                oRng.Collapse 1
                oRng.MoveEndWhile Chr(32)
                oRng.Text = ""
                oCell.Range.ParagraphFormat.TabStops.Add _
                        Position:=iPos, _
                        Alignment:=wdAlignTabDecimal, _
                        Leader:=wdTabLeaderSpaces
            Next oCell
        Next i
    End With
    Set oTable = Nothing
    Set oCell = Nothing
    Set oRng = Nothing
End Sub
__________________
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
Reply

Tags
decimal tab, table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Decimal tabs with space as thousands separator harry Word 1 12-22-2023 02:59 PM
Macro for setting decimal tabs in tables Macro to delete tabs in Word Shelley Lou Word VBA 16 12-21-2020 06:34 AM
Macro for setting decimal tabs in tables I need a macro to format images and remove tabs. help LuisXVI Word VBA 4 11-12-2018 03:12 PM
Setting tabs relative to block of text kirkm Word 8 09-06-2016 07:54 PM
Pulling 2 digits before a decimal point from adjoining cell then zeros after decimal jadess916 Excel 1 06-26-2014 03:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft