我试图创建一个函数来找出这个选择,但是对我的基本技能来说有点困难。
根据提供的答案编辑问题
Function relRange(rangeIn As Range, activeCell) As Integer
relRange = 0
If (rangeIn.Rows.Count = 6) And (rangeIn.Columns.Count = 6) Then ' range has double merged cells
' comparison code to determine where the activecell is relative to the 3x3 array
If rangeIn.Cells(5, 1).Address = activeCell Then relRange = 1 '1
If rangeIn.Cells(3, 1).Address = activeCell Then relRange = 2 '2
If rangeIn.Cells(5, 3).Address = activeCell Then relRange = 3 '3
If rangeIn.Cells(3, 3).Address = activeCell Then relRange = 4 '4
If rangeIn.Cells(1, 1).Address = activeCell Then relRange = 5 '5
If rangeIn.Cells(5, 5).Address = activeCell Then relRange = 6 '6
If rangeIn.Cells(1, 3).Address = activeCell Then relRange = 7 '7
If rangeIn.Cells(3, 5).Address = activeCell Then relRange = 8 '8
If rangeIn.Cells(1, 5).Address = activeCell Then relRange = 9 '9
End If
End Function
我现在有了这个功能,很惊讶没有更简单的方法。