by Allen Wyatt
(last updated April 6, 2020)
Keith has a worksheet that uses columns A through H. He would like to be able to widen each column by a proportional amount. For instance, if he selects all 8 columns, it would be great if he could grab the right edge of column H and as he drags right, all of the columns would be proportionally spaced out. He wonders if there is a way to do this type of column widening.
To better understand what Keith is talking about, perhaps an example is in order. The normal way of adjusting column width using the mouse is to select the columns and then drag a divider between the column headers to the right or left. Let's say that column A's width is 5, column B is 10, and column C is 15. If you select A:C and drag the divider at the right side of the column C header to 20, that is an increase of 33% for column C. Ideally, both column A and B would also be resized by 33% (as Keith desires), but they are, instead, both set to a width of 20 to match column C.
Further, holding down a modifier key (Ctrl, Alt, or Shift) as you drag the mouse has no effect; the column widths are still all set equal to each other. If you try to right-click and drag, that does nothing except display a Context menu. Thus, from all the testing we've been able to do, there is no way to proportionally adjust column widths in in Excel that we've been able to discover.
Perhaps the easiest way is to use a macro to adjust the column widths. The following is a good example of such an approach.
Sub ProportionalWidth() Dim C As Range Dim sRaw As String Dim sTemp As String Dim P As Single sRaw = InputBox("Increase width by how what % (0 to 100)?") P = Val(sRaw) If P >= 0 And P <= 100 Then P = 1 + (P / 100) sTemp = "" For Each C In Selection.Columns sTemp = sTemp & "Column " & ColumnLetter(C.Column) sTemp = sTemp & ": " & C.ColumnWidth & " ==> " C.ColumnWidth = C.ColumnWidth * P sTemp = sTemp & C.ColumnWidth & vbCrLf Next C MsgBox sTemp Else MsgBox "Out of range; no adjustment made" End If End Sub
Function ColumnLetter(Col As Long) As String Dim Arr Arr = Split(Cells(1, Col).Address(True, False), "$") ColumnLetter = Arr(0) End Function
There are actually two macros in this example. The first (ProportionalWidth) changes the width of whatever columns you've selected. The second (ColumnLetter) is used to convert a numeric column number into the column letters. It is only used in putting together the report (in sTemp) of the before and after widths of the columns.
When you select columns and run the macro, it prompts you for how much wider you want to make those columns. Enter a number between 0 and 100, click OK, and the columns are widened by that percentage. In addition, you'll see a message box that shows the original width of each column and the adjusted width.
Note that this macro only widens columns. If you wanted use it to also make columns proportionally narrower, you would need to modify it to, perhaps, handle negative values.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13429) applies to Microsoft Excel 2007, 2010, 2013, and 2016.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
If you were trying to format a worksheet and nothing you did could make the first two columns appear, would you be ...Discover More
One way you can widen the columns in a worksheet to fit whatever is in the column is by double-clicking the right edge of ...Discover More
Want to hide a column so it doesn't appear in the worksheet? It's easy to do using the formatting capabilities of Excel.Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.