【发布时间】:2022-07-13 05:40:23
【问题描述】:
SelectionChange 事件对选择范围有任何限制吗?在第一行“ClickCol”标题下的单元格上选择后,我在执行简单范围选择时遇到运行时错误。
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim shelvesSht As Worksheet
Set shelvesSht = ActiveSheet
Dim selectionRange As Range
If ActiveSheet.Cells(1, ActiveCell.Column).Value = "ClickCol" Then
Dim headerRow As Long
headerRow = 1
selectionRange = shelvesSht.Cells(1, 1) '<--- Here is where I get the error
MsgBox "Selected cell in Click Col... Moving on"
End If
End Sub
此后我的目标是选择整个第一行 selectionRange.EntireRow.Select 然后使用此选择来查找各种标题的列号。
【问题讨论】:
标签: excel select event-handling runtime-error