' This is meant to be run in a module and must be called
Sub tester()
Dim lastRow As Long, testString As String, rng2Search As Range
lastRow = ActiveSheet.Range("G65536").End(xlUp).Row
For i = 1 To lastRow
If ActiveSheet.Range("G" & i) = "Verbal" Or _
ActiveSheet.Range("G" & i) = "Written" Or _
ActiveSheet.Range("G" & i) = "Demonstrated" Then
Set rng2Search = Sheets("DO NOT DELETE").Range("C2:C4").Find(ActiveSheet.Range("G" & i), LookIn:=xlValues)
If Not rng2Search Is Nothing Then
ActiveSheet.Range("I" & i).Value = Sheets("DO NOT DELETE").Range("D" & rng2Search.Row).Value
End If
End If
Next i
Set rng2Search = Nothing
End Sub
' This will run automatically if in the worksheet module
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng2Search As Range
If Mid(Target.Address, 1, 2) = "$G" Then
Set rng2Search = Sheets("DO NOT DELETE").Range("C2:C4").Find(Target.Value, LookIn:=xlValues)
If Not rng2Search Is Nothing Then
ActiveSheet.Range("I" & Target.Row).Value = Sheets("DO NOT DELETE").Range("D" & rng2Search.Row).Value
End If
End If
End Sub
1 回答
确保您的活动表是具有下拉值的活动表 . 您必须拨打电话才能运行此功能 .
每当G列中的单元格发生更改时,您也可以将其更改为在工作表模块上运行 . 打开包含下拉值的工作表模块并将其粘贴到那里 .