如何使用键盘快捷键取消选择 Excel 单元格?

ahm*_*l88 14 keyboard-shortcuts microsoft-excel

可以使用键盘快捷键Ctrl+Click选择多个 Excel 单元格(连续或不连续)。

如何取消选择这些先前选择的单元格中的一个或多个?

Leo*_*iro 5

通过使用 SHIFT 和/或 CTRL 键,您可以选择不连续的范围。但是,如果您错误地选择了一个单元格或区域,则没有内置的方法可以将其从选择中删除,而不会丢失整个选择并且必须重新开始。本页描述了 VBA 过程,UnSelectActiveCell 和 UnSelectCurrentArea,它们将从当前选择中删除活动单元格或包含活动单元格的区域。选择中的所有其他单元格将保持选中状态。

最好的办法是将这些添加到您的个人宏工作簿,以便它们可用于 Excel 中所有打开的工作簿。

此过程将从选择中删除活动单元格

Sub UnSelectActiveCell()
    Dim R As Range
    Dim RR As Range
    For Each R In Selection.Cells
        If StrComp(R.Address, ActiveCell.Address, vbBinaryCompare) <> 0 Then
            If RR Is Nothing Then
                Set RR = R
            Else
                Set RR = Application.Union(RR, R)
            End If
        End If
    Next R
    If Not RR Is Nothing Then
        RR.Select
    End If
End Sub
Run Code Online (Sandbox Code Playgroud)

此过程将从选择中删除包含活动单元格的区域。

Sub UnSelectCurrentArea()
    Dim Area As Range
    Dim RR As Range

    For Each Area In Selection.Areas
        If Application.Intersect(Area, ActiveCell) Is Nothing Then
            If RR Is Nothing Then
                Set RR = Area
            Else
                Set RR = Application.Union(RR, Area)
            End If
        End If
    Next Area
    If Not RR Is Nothing Then
        RR.Select
    End If
End Sub
Run Code Online (Sandbox Code Playgroud)

  • God excel 太老了哈哈 (2认同)