简体   繁体   中英

Change column width based on another cell value

In excel, I have two three columns and after transpose I have some change to make. Let the data be ::

A   B   C
a   K   .2 
a   Q   .23
a   R   .45
b   L   .3
b   S   .12
c   M   .43
d   N   .54
e   O   .32
f   P   .067

After transpose::
a K Q R
b L S
c M
d N
e O
f P

Each row is filled by whatever values I have in column B corresponding to column A. Now the problem is the cell in which I fill KLSQR ie column B values should be of different sized and in ratio of their weight which is column C.For example K should be 0.2, R should be 0.45 or in the same ratio. And since these are written one below the top entire column could not be changed for "a" since the next row cells would be again of different sizes each.

I think this could be achievable by macro but I am not sure about that.Please let me know if you need any further information. Thanks!

Not exactly sure what you mean from your wording but it is certainly easy to change column width via vba.

If you want to change column F based on value of C3 then you need: Range("F:F").ColumnWidth = Range("C3").Value

Obviously qualify your range so it's specific to whatever sheet / workbook you want etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM