Hightlight活动行/列在Excel中不使用VBA? [英] Hightlight active row/column in Excel without using VBA?

查看:200
本文介绍了Hightlight活动行/列在Excel中不使用VBA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要实现的是突出显示活动行或列。我使用VBA解决方案,但是每次使用 Selection_change 事件我失去了撤消我的工作表中任何更改的机会。

What I want to achieve is to highlight active row or column. I used VBA solutions but everytime Selection_change event is used I am loosing chance to undo any changes in my worksheet.

有没有办法在没有使用VBA的情况下激活活动行/列?

Is there a way to somehow hightlight active row / column without using VBA?

推荐答案

我不认为没有使用VBA可以完成,但它可以完成,而不会丢失您的撤消历史记录:

I don't think it can be done without using VBA, but it can be done without losing your undo history:

在VBA中,将以下内容添加到工作表对象中:

In VBA, add the following to your worksheet object:

Public SelectedRow as Integer
Public SelectedCol as Integer

Private Sub Worksheet_SelectionChange(ByVal Target as Range)
    SelectedRow = Target.Row
    SelectedCol = Target.Column
    Application.CalculateFull ''// this forces all formulas to update
End Sub

创建一个新的VBA模块并添加以下内容:

Create a new VBA module and add the following:

Public function HighlightSelection(ByVal Target as Range) as Boolean
    HighlightSelection = (Target.Row = Sheet1.SelectedRow) Or _
        (Target.Column = Sheet1.SelectedCol)
End Function



最后,使用条件格式来突出显示基于HighlightSelection公式的单元格:

Finally, use conditional formatting to highlight cells based on the 'HighlightSelection' formula:

这篇关于Hightlight活动行/列在Excel中不使用VBA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆