提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

在Excel中单击或选择单元格时如何更改单元格颜色?

本文将向您展示如何在单击单元格时更改单元格颜色的一些方法,并在Excel中选择单元格区域时更改高亮显示的颜色。

使用VBA代码单击单元格时更改单元格颜色

使用VBA代码选择单元格时更改突出显示的颜色

使用Kutools for Excel突出显示活动单元格的整个行和列


在Excel中单击以突出显示所选单元格的行和列:

Kutools for Excel's 阅读布局 实用程序可帮助您快速突出显示Excel中所选单元格的行和列。 看截图: 立即下载Kutools for Excel的全功能60天免费试用版!

Kutools for Excel:比200方便的Excel加载项,可以在60天免费试用。 立即下载免费试用版!

Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel - 最佳办公生产力工具将解决您的大部分Excel问题
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 适用于Office 2007-2019和365; 支持所有语言; 在公司轻松部署; 全功能60天免费试用。

使用VBA代码单击单元格时更改单元格颜色

在这里,你可以改变一个单元格的背景颜色,双击它或用下面的VBA代码右键单击它。

1。 在工作表中,点击时将更改单元格颜色,右键单击工作表选项卡并单击 查看代码 从右键菜单。

2。 在里面 Microsoft Visual Basic for Applications 窗口,请复制并粘贴下面的VBA代码到 代码 窗口。

VBA:单击时更改单元格颜色

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    Target.Interior.Color = vbRed
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    Target.Interior.Color = vbGreen
End Sub

3。 按 其他 + Q 键同时关闭 Microsoft Visual Basic for Applications 窗口。

然后,当你双击一个单元格时,它会被涂成红色。 当你右键单击一个单元格时,它将被着绿色。 看截图:


使用VBA代码选择单元格时更改突出显示的颜色

默认情况下,选择单元格范围时,突出显示的颜色为灰色。 如果您想让选定的范围更突出,可以将突出显示的颜色更改为您需要的颜色。 请做如下。

1。 右键单击要更改所选范围的突出显示颜色的工作表选项卡,然后单击 查看代码 从右键菜单。

2。 在里面 Microsoft Visual Basic for Applications 窗口,请复制并粘贴下面的VBA代码到 代码 窗口。

VBA代码:更改所选范围的高亮颜色

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Target
        .Worksheet.Cells.FormatConditions.Delete
        .FormatConditions.Add xlExpression, , "TRUE"
        .FormatConditions(1).Interior.Color = vbYellow
    End With
End Sub

3。 按 其他 + Q 键同时关闭 Microsoft Visual Basic for Applications 窗口。

从现在起,所选范围或单元格的高亮颜色将更改为黄色。 当您单击另一个单元格或单元格区域时,单元格将自动着色。


使用Kutools for Excel突出显示活动单元格的整个行和列

如果您正在处理大型工作表,则需要突出显示活动单元格的整个行和列,以便更轻松地进行阅读。 在这里 阅读布局 实用程序 Kutools for Excel 可以帮你。

Kutools for Excel : 与超过300方便的Excel加载项,在60天免费试用没有限制.

1。 点击 Kutools > 阅读布局。 看截图:

然后启用阅读布局,您可以看到活动单元的行和列立即高亮显示。

注意:您可以根据您的需要更改阅读版式设置,如下所示。

提示。如果您想免费试用此实用程序,请转到 免费下载软件 首先,按照上述步骤进行操作。


Office Tab - 在Excel中选项卡式浏览,编辑和管理工作簿:

Office选项卡将Web浏览器(如Google Chrome,Internet Explorer新版本和Firefox)中显示的选项卡界面带到Microsoft Excel。 它将是一个节省时间的工具,在您的工作中无可比拟。 见下面的演示:

点击免费试用Office Tab!

Excel的Office选项卡


使用Kutools for Excel突出显示活动单元格的整个行和列

Kutools for Excel 包含了比300更方便的Excel工具。 免费试用60天无限制。 立即下载免费试用!


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Vishnu Subind · 3 months ago
    Hi guys, so i used to first code to change the cell colour to green/red on doubleclick/rightclick. I would like this code, however, to work just on a specific range of cells, in my case D9:P9. can someone help me on how to do that? Im new at VBA
  • To post as a guest, your comment is unpublished.
    rahayu · 5 months ago
    trimakasih
  • To post as a guest, your comment is unpublished.
    rahayu · 5 months ago
    td muncul=tidak muncul
  • To post as a guest, your comment is unpublished.
    rahayu · 5 months ago
    Salam...
    sy sudah install kutools, tp kok td muncul tab kutools di layar excel ya? gmn cara mmunculkannya?trimakasih
  • To post as a guest, your comment is unpublished.
    Cr Decima · 6 months ago
    I have a problem.
    I want change color of one hyperlink if it had linked with one PDF to RED and if had not link with one PDF will show BLUE color.
    How can I do now?
    • To post as a guest, your comment is unpublished.
      crystal · 6 months ago
      Good day,
      Sorry can't help you with that. Thanks for commenting.
  • To post as a guest, your comment is unpublished.
    Devika Kalika · 8 months ago
    I tried the "Change the highlighted color when cells are selected with VBA code" option and saved my excel as Macro Enabled Worksheet. Now the last cells that were selected are highlighted and won't highlight other cells when selected. I've deleted code and reentered and saved, but still no change. I can't remove the previous highlight either. I'm at lost on what to do.
    • To post as a guest, your comment is unpublished.
      crystal · 7 months ago
      Hi,
      The code works well in my case after saving the workbook as an Excel Macro-Enabled Workbook.
      Can you tell me your Excel version?
  • To post as a guest, your comment is unpublished.
    Jason · 10 months ago
    Is there a way to just apply this to certain cells while leaving other cells with available for number entering?
  • To post as a guest, your comment is unpublished.
    Slaxx · 1 years ago
    hi. just a little heads up. i'm using office 2007.
    i tried your code, and while it did work, it wasn't what i was looking for. so i just deleted the code completely. but the last selected/active cell before i deleted the code is still green (i changed the color from vbYellow to vbGreen), and the color won't go away. it's not affected by fill color either.
    the simplest solution i found was to just delete the cell. copying and pasting will not work, it will also copy the color.
    just thought i'd let you know. you might find another solution/troubleshooting for this, besides deleting and manual entry. still, thanks! i confirm that the code works :)
  • To post as a guest, your comment is unpublished.
    Michelle · 1 years ago
    I love how easy formatting my worksheet the code for "change cell color when clicking on it" would make my daily work! I am hitting a snag though. When I copy my Blank Sheet with the code entered as described, I get a error. It runs great until I create new sheets. I am a novice at coding and am working from textbooks and the internet. I appreciate any help you will offer!
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Dear Michelle,
      I followed the steps as you described, but the code also worked in my case. Can you tell me your Office version?
      Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    madhav neupane · 1 years ago
    thank you thank you so much. I appreciate you for this.