0
我在工作表中有一堆范围名称(大多数是单个单元格)。当我更改名为“Grade”的单元格时,我希望它的值出现在另一个名为“GrdSrchSttng”(6 x 1范围)的范围中作为最后一个值。但是为了做到这一点,我需要知道名为“成绩”的特定单元格发生了变化。 The solution to this question does not work.返回范围的名称。
我尝试这样做:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim isIn As Boolean
Dim i As Integer
Dim r As Range
Set r = ActiveSheet.Range("GrdSrchSttng")
If Target.Name.Name = "Search!Grade" Then ' <== this si the line I have the issue with
Select Case Target.Value
Case "All"
r.ClearContents
r.Cells(1, 1).Value = "All"
Case ""
r.ClearContents
Target.Value = "All"
r.Cells(1, 1).Value = "All"
Case Else
If r(1, 1).Value = "All" Then
r.ClearContents
End If
i = 1
Do While r(i, 1).Value <> ""
If r(i, 1).Value = Target.Value Then
isIn = True
End If
i = i + 1
Loop
If Not isIn Then
r(i, 1).Value = Target.Value
End If
End Select
End If
End Sub
嗨,谢谢,很好的解决方法。我决定使用这个而不是我的“下一个单元格检查”,因为我更喜欢这个。仍然不明白为什么.name.name不起作用。有点沮丧。但无论如何,非常感谢。 – PBD10017
不客气,谢谢你的接受。 :) – Manhattan
@ BK201我有相同的方法,但在测试期间,我没有得到所需的结果。这张纸上什么都没有发生。所以我没有发布它作为答案。任何想法为什么? :) – L42