vba 如果单元格 a1=text 那么单元格 a2=bold。我如何在excel中做到这一点?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8099645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 14:27:03  来源:igfitidea点击:

if cell a1=text then cell a2=bold. How do i do it in excel?

excelvba

提问by user1042423

if cell a1 is equal to some text then i want to select the corresponding cell in the same row to be in bold and italic. for eg if there is text "james" in cell a1 then i want to make the other cell a2, containing an integer, in bold and italic. This has to be done for a selective range in the worksheet, so wherever there is james i need the corresponding cell to be bold and italic. Please help me out here.

如果单元格 a1 等于某个文本,那么我想选择同一行中的相应单元格以粗体和斜体显示。例如,如果单元格 a1 中有文本“james”,那么我想制作另一个单元格 a2,其中包含一个整数,以粗体和斜体显示。这必须在工作表中的一个选择性范围内完成,所以无论哪里有詹姆斯,我都需要相应的单元格为粗体和斜体。请帮帮我。

回答by themel

Your Google term is conditional formatting.

您的 Google 术语是条件格式

回答by Tom

did you try simple conditional formatting?

你试过简单的条件格式吗?

in 2007 : Conditional Formatting --> new rule --> Use a formula to determine which cells to format

2007 年:条件格式 --> 新规则 --> 使用公式确定要设置格式的单元格

formula : =IF(A1="james",TRUE,FALSE)"where "james" would of course better be replace by a reference to a cell.

公式:=IF(A1="james",TRUE,FALSE)"其中“james”当然最好用对单元格的引用替换。

回答by minnow

  1. Select cell b1
  2. On the Home tab, in the Style group, click Conditional Formatting, click New Rule...
  3. select "Use a formula to determine which cells to format"
  4. Set the formula to =A1="james". Take Tom's advice and make "james" a cell reference.
  5. Click the Format... button, select Font Style "Bold Italic" and click OK
  6. Click Ok to close the New Formatting Rule dialog

  7. you should still have cell b1 selected

  8. On the Home tab, in the Style group, click Conditional Formatting, Manage Rules...
  9. Find the rule you just created and change its "Applies to" from =$B$1 to =B1. This makes the "applies to" reference relative rather than fixed (that's what the $ is doing) in order for copy and paste to automagically change your formulas to the destination row/column.
  10. click OK

  11. Copy and paste cell b1 to the other cells in the b column.

  1. 选择单元格 b1
  2. 在开始选项卡的样式组中,单击条件格式,单击新建规则...
  3. 选择“使用公式确定要设置格式的单元格”
  4. 将公式设置为 =A1="james"。接受 Tom 的建议,将“james”作为单元格引用。
  5. 单击格式...按钮,选择字体样式“粗斜体”,然后单击确定
  6. 单击“确定”关闭“新建格式规则”对话框

  7. 您仍然应该选择单元格 b1

  8. 在主页选项卡上的样式组中,单击条件格式、管理规则...
  9. 找到您刚刚创建的规则并将其“适用于”从 =$B$1 更改为 =B1。这使得“适用于”引用相对而不是固定的(这就是 $ 正在做的事情),以便复制和粘贴自动将您的公式更改为目标行/列。
  10. 单击确定

  11. 将单元格 b1 复制并粘贴到 b 列中的其他单元格。

I hope this helps!

我希望这有帮助!