急求高手指点,VB编辑中出现错误,如何在过程中和给定的条件做整体比较,,,谢谢

2025-01-04 11:50:28
推荐回答(2个)
回答1:

Private Sub Worksheet_Change(ByVal Target As Range)
'MsgBox
If Target.Address = "$A$1" Then
vl = Cells(Target.Row, Target.Column)
xr = Target.Row: xc = Target.Column
If Len(vl) = 0 Then Exit Sub ''空值退出
On Error Resume Next
x = ActiveSheet.Name
'MsgBox x
For Each Sh In ThisWorkbook.Sheets
If Sh.Name = x Then GoTo a_next
y = Sh.Name
'MsgBox y
Set sj = Worksheets(y)
ed = sj.[A65536].End(xlUp).Row

For i = 1 To ed

If sj.Cells(i, 1).Value = vl Then

Worksheets(x).Cells(xr, xc + 1) = sj.Cells(i, 2).Value
Exit For
End If

Next

a_next: Set sj = Nothing
Next
End If
End Sub

回答2:

挺复杂