简体   繁体   English

根据另一个单元格值更改列宽

[英]Change column width based on another cell value

In excel, I have two three columns and after transpose I have some change to make. 在excel中,我有两个三列,转置后,我需要进行一些更改。 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. 每行都由我在B列中与A列相对应的任何值填充。现在的问题是我填充KLSQR的单元格,即B列的值应具有不同的大小和权重比,即C列。 K应为0.2,R应为0.45或相同比例。 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. 并且由于将这些写在最下面的整个列的下方,因此不能将其更改为“ a”,因为下一行的行单元将再次具有不同的大小。

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. 不能完全确定您的措辞是什么意思,但是通过vba更改列宽当然很容易。

If you want to change column F based on value of C3 then you need: Range("F:F").ColumnWidth = Range("C3").Value 如果要基于C3的值更改列F,则需要: Range("F:F").ColumnWidth = Range("C3").Value

Obviously qualify your range so it's specific to whatever sheet / workbook you want etc. 显然可以限定您的范围,因此它特定于您想要的任何工作表/工作簿等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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