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:
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?
Thanks,
Answer
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.
No comments:
Post a Comment