我目前有这个代码:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lastrow As Long
Dim rngList As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set rngList = Range("AB3").CurrentRegion
If Target.Cells.Count > 1 Then Exit Sub
On Error Resume Next
If Not Intersect(Target, Range("B18:B19")) Is Nothing Then ' user is in column-A
Target.Value = Application.WorksheetFunction.VLookup(Target.Value, rngList, 2, False)
End If
Set rngList = Nothing
End Sub
和
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lastrow As Long
Dim rngList As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set rngList = Range("AC3").CurrentRegion
If Target.Cells.Count > 1 Then Exit Sub
On Error Resume Next
If Not Intersect(Target, Range("B10:B11")) Is Nothing Then ' user is in column-A
Target.Value = Application.WorksheetFunction.VLookup(Target.Value, rngList, 2, False)
End If
Set rngList = Nothing
结束子
我想将它们结合起来,以便我可以同时使用它们,但我不知道如何在没有冲突的情况下这样做,任何帮助将不胜感激,谢谢。