简体   繁体   English

根据单元格值添加x个格式化单元格的数量

[英]Add x number of formated cells based on cell value

I would like to format x number of rows based on a cell's value (it gets its value from vLookup). 我想根据单元格的值格式化x的行数(它从vLookup获取其值)。 For example if I in cell A1 enter value 3 then I want cell C1, C2 and C3 to get the following values.. 例如,如果我在单元格A1中输入值3,那么我希望单元格C1,C2和C3获得以下值。

C1 = "Enter text for row 1"
C2 = "Enter text for row 2"
C3 = "Enter text for row 3"

And so on .. 等等 ..

Can this be done using formulas or only by VBA? 可以使用公式或仅通过VBA完成吗?

In C1 enter: C1中输入:

=IF(ROW()>$A$1,"",IF($A$1=0,"","Enter text for row " & ROW()))

and copy down as far as the maximum possible value in A1 并复制到A1中的最大可能值

在此处输入图片说明

For the green highlighting, use conditional formatting. 对于绿色突出显示,请使用条件格式。

Select cell D1 for example as the first cell to right of your "Enter with text" column. 例如,选择单元格D1作为“用文本输入”列右侧的第一个单元格。

Home --> conditional formatting --> New Rule -->Use a formula to determine which cells to format (bottom option). 主页->条件格式->新规则->使用公式来确定要格式化的单元格(底部选项)。

In Formula bar type =C1<>"" 在公式栏中键入= C1 <>“”

Don't use anchors (any $'s) on C1! 不要在C1上使用锚点(任何$)!

Then use the format button, bottom right of existing box, Fill tab, select preferred green colour. 然后使用格式按钮,现有框的右下角,“填充”选项卡,选择首选的绿色。 OK then OK. OK,然后OK。

Copy cell and drag down to more than cover maximum expected returns of "Enter with text" 复制单元格并向下拖动以覆盖“输入文字”的最大预期收益

Hope that helps 希望能有所帮助

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

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