Microsoft Office Forums Problem with Cell Margins

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2011, 10:02 PM
Aston Aston is offline Problem with Cell Margins Windows XP Problem with Cell Margins Office 2007
Novice
Problem with Cell Margins
 
Join Date: May 2011
Posts: 15
Aston is on a distinguished road
Default Problem with Cell Margins

Hello everyone,



I work as an editor for an audit firm. From time to time, I get reports with tables that have a problem that I hope you can help me solve.

I am sure it has to do with Cell Margins settings but no matter what I do with them, it doesn't seem to fix the issue completely.

I use decimal tabs to align numbers in tables. I just select all the columns in a table, put a decimal tab and all the numbers get aligned nice and fast.

The problem with some tables is that different cells within a single table have different cell margins. So I have to go to these cells and adjust the position of the decimal tab to make the number properly aligned and, apart from being very annoying, it can also take a long time, especially if a table is very long and full of such glitches.

I tried selecting the table and going to "Table Tools" - "Layout" - "Cell Margins" and setting Left and Right Margins to some number, hoping it would have an effect on all the cells and make their margins equal. But no, they still retain their "glitchy" margins

I attached a document that has a problem table so you can see what I mean and maybe find a way of fixing it.

Note that cells in "Accumulated deficit" column have different margins. (And numbers are not aligned properly)

How can I make the cell margins equal in the entire table???

Thank you all for your help.
Attached Files
File Type: docx ProblemTable.docx (16.7 KB, 4 views)
Reply With Quote
  #2  
Old 05-08-2011, 01:26 AM
macropod's Avatar
macropod macropod is offline Problem with Cell Margins Windows 7 32bit Problem with Cell Margins Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Aston,

Although the various 'currency' cells in your table have a "Table numbers1" Style attached to them, it look like someone has been manually overriding that. Some of the 'currency' cells also have a different top/bottom padding than other 'currency' cells and the table defaults. It's these two things together that seem to be messing up the formatting. The following macro goes through all the cells with the "Table numbers1" Style attached, in all tables in the document, and re-formats them with the "Table numbers1" Style correctly applied and the cell padding the same as the table generally:
Code:
Sub FixTables()
Dim Tbl As Table, oCel As Cell, Rng As Range, bBld As Boolean
With ActiveDocument
  For Each Tbl In .Tables
    For Each oCel In Tbl.Range.Cells
      With oCel
        If .Range.Style = "Table numbers1" Then
          bBld = .Range.Font.Bold
          .TopPadding = Tbl.TopPadding
          .BottomPadding = Tbl.BottomPadding
          .RightPadding = Tbl.RightPadding
          .LeftPadding = Tbl.LeftPadding
          .Range.Style = "Table numbers1"
          .Range.Font.Bold = bBld
        End If
      End With
    Next
  Next
End With
End Sub
Note: the code captures and re-applies the font bolding for the cells concerned. If a 'bold' character Style had been applied to these cells, that wouldn't be necessary.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 05-08-2011, 04:47 AM
Aston Aston is offline Problem with Cell Margins Windows XP Problem with Cell Margins Office 2007
Novice
Problem with Cell Margins
 
Join Date: May 2011
Posts: 15
Aston is on a distinguished road
Default

Macropod,

let me express my greatest appreciation for your help. You are truly a terrific expert.

I applied your macro and it's done wonders.

Now I'm going to spend some time to understand what this macro is actually doing, because I'm not sure I have a full understanding of what's really going on.

Thank you.

Last edited by Aston; 05-08-2011 at 05:49 AM. Reason: Update
Reply With Quote
  #4  
Old 05-08-2011, 05:26 AM
macropod's Avatar
macropod macropod is offline Problem with Cell Margins Windows 7 32bit Problem with Cell Margins Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Quote:
Originally Posted by Aston View Post
Now I'm going to spend some time to understand what this macro is actually doing, because I'm not sure I have a full understanding of what's really going on.
Well, I suppose if you'd known enough vba to understand the macro from the outset, you'd have written something like it for yourself

I'm glad to hear you're interested enough to want to study the code - that's a good way to build up your own skills.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 05-08-2011, 05:50 AM
Aston Aston is offline Problem with Cell Margins Windows XP Problem with Cell Margins Office 2007
Novice
Problem with Cell Margins
 
Join Date: May 2011
Posts: 15
Aston is on a distinguished road
Default

I just realized that this "Cell Margins" button on Table Tools' Layout tab always shows (default?) margins for the entire table and not for a specific cell. Looking at the ruler, it is visually noticeable that the margins in different cells are different, but when I place the cursor in these cells and click this button, it always shows the same values regardless of what the ruler shows.

I found out that if you want to see the actual margins for a specific cell, you have to right-click the cell, go to "Table Properties" - "Cell Tab" - click on the "Options" button and here it is, a deeply-buried-but-so-much-needed-in-my-case dialog box called Cell Options (or is there a shortcut???). Here you can adjust cell margins as needed or just check "Same as the whole table" box. And the problem is solved.

Thank you once again, macropod
Reply With Quote
  #6  
Old 05-08-2011, 06:10 AM
macropod's Avatar
macropod macropod is offline Problem with Cell Margins Windows 7 32bit Problem with Cell Margins Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Aston,

Yes, it only shows the table defaults, not the settings for the current cell. And, while there's an option for each cell that you can get to and click to re-set it, that doesn't seem to work for more than one cell at a time and isn't exposed to vba. Hence the need to reset all the values individually, and on a cell-by cell basis.

The keyboard access to the dialogue box is Alt-a, r, e, Alt-o. Not exactly a shortcut, but there it is.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 07-15-2011, 12:02 PM
sleake sleake is offline Problem with Cell Margins Windows XP Problem with Cell Margins Office 2007
Advanced Beginner
 
Join Date: Jul 2011
Posts: 60
sleake is on a distinguished road
Default Problem with Cell Margins

Paul Edstein aka Macropod:
Thank you ever so much for the code posted re cell padding. Our project is now required to have a specific cell padding for tables, but I have had many problems with getting it to apply properly -- and stay -- when selecting the entire table and applying the padding. (We also have numerous documents with numerous table, so this new requirement adds much time and effort.)

I modified your code to include Allow row to break across pages = False and to do the cell padding. It is like magic -- and an answer to the prayers of the three editors on the project.

Thanks again.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inconsistent Margins judyfogarty Word 0 08-01-2010 02:54 AM
How can I fill cell color starting from Cell D5 using Conditional formatting instead Learner7 Excel 0 07-08-2010 05:50 AM
How can I make a cell color RED under the Today's date cell? Learner7 Excel 2 07-08-2010 12:52 AM
Problem with Cell Margins Margins xGAME-OVERx Word 8 10-24-2009 06:39 AM
Auto-populate an MS Word table cell with text from a diff cell? dreamrthts Word Tables 0 03-20-2009 01:49 PM


All times are GMT -7. The time now is 02:23 PM.


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