简体   繁体   English

Excel根据其他单元格值创建“条形”或填充一系列单元格

[英]Excel create “bars” or fill series of cells based on other cell value

I want to create a automatically generated "timeline" as i fill a column with numbers. 我想用数字填充一列时创建一个自动生成的“时间轴”。 Lets say C4 gets the value of 5. Then I want D4:I4 to be either filled with a 1 (so I can use conditional formatting), or filled with a specific color. 假设C4的值为5。然后我希望D4:I4填充为1(这样我就可以使用条件格式)或填充特定的颜色。 This should be the case for more than 300 rows, C4:C350. 对于300多个行,C4:C350,应该是这种情况。 Is there a way to use normal formulas or do I need to write a macro. 有没有办法使用普通公式,或者我需要写一个宏。 I need it to be as easily used as possible since a lot of people not used to work with macros should be able to use it. 我需要尽可能容易地使用它,因为很多不习惯使用宏的人都应该能够使用它。

ABCDEFGHIJKL Art no1 Name1 Amount 1 2 3 4 5 6 7 8 9 Art no2 Name2 Amount 1 2 3 4 5 Art no2 Name2 Amount 1 2 3 4 5 6 7 8 9 10 11 12 ABCDEFGHIJKL产品编号1名称1数量1 2 3 4 5 6 7 8 9产品编号2名称2数量1 2 3 4 5产品编号2名称2数量1 2 3 4 5 6 7 8 9 10 11 12

And so on... 等等...

  • Select the range you want to be colored, ie D4:M350. 选择要着色的范围,即D4:M350。 M depends on the max value your column C will have. M取决于列C的最大值。 In this example, I assumed that 10 will be the max value (D, E, F, G, H, I, J, K, L, M = 10 columns). 在此示例中,我假定最大值为10(D,E,F,G,H,I,J,K,L,M = 10列)。

  • On the Home tab, click Conditional Formatting -> New Rule -> Format values where this formula is true 在“开始”选项卡上,单击“条件格式”->“新规则”->“在此公式为真的情况下格式化值”

  • Enter this formula: 输入以下公式:

     =COLUMN(D4)-COLUMN($C4)<=$C4 
  • Click the Format button, choose your desired cell format and you're good to go. 单击格式按钮,选择所需的单元格格式,一切顺利。

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

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