Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of columns on a worksheet, these columns do not have the same width, But all these columns must have in total a given width. How can I do that, keeping the ratio?

So I have this:

enter image description here

Let's now say that I want this to be 15 cm, How can I do it keeping the ratio, without having to set manually each column width?


share|improve this question
Care to provide a sample? What ratio? – teylyn Jun 9 '13 at 20:40
I've edited my post in order to give one – lpostula Jun 10 '13 at 14:43
up vote 0 down vote accepted

Your best bet may be a VBA subroutine (a.k.a. a macro).  Here’s a kludgy proof-of-concept:

Sub resize_columns()
    Columns("A").ColumnWidth = Columns("A").ColumnWidth * (15 / 10.5)
    Columns("B").ColumnWidth = Columns("B").ColumnWidth * (15 / 10.5)
    Columns("C").ColumnWidth = Columns("C").ColumnWidth * (15 / 10.5)
    Columns("D").ColumnWidth = Columns("D").ColumnWidth * (15 / 10.5)
End Sub

I’m sure somebody here can improve on the above.

share|improve this answer
Using Scott's approach as a starting point, you could have a cell in the sheet that determines how many Excel width points or pixels (different units!!) the total table width should be. Then have a reference table somewhere, where you define the percentage width of each column. Then you can use these percentages in the VBA code and convert them into width or pixels. – teylyn Jun 11 '13 at 6:57

You can select more than one column by clicking and dragging into the column letters. Then drag the border between any of the selected column headers to make all columns the same size. All cells in one column will always be the same width. You cannot have an individual cell be wider than the other cells in the column.

You can use merged cells to make a cell span more than one column, but that is not advisable, because merged cells cause many problems.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .