在我的代码下面,以下行似乎存在问题:
Range("B4").Formula = "=index(C5:AV51,1,column(ActiveCell)-2)"
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For Each Cell In Range("C6:AV51")
Range("B4").Formula = "=index(C5:AV51,1,column(ActiveCell)-2)"
If ActiveCell.Row - ActiveCell.Column < 3 Then
ActiveCell.Formula = "=vlookup(index(B5:AV51,row()-4,1),'[" & Range("B4").Value & ".xlsx]Sheet1'!A1:E70,4,false)"
ElseIf ActiveCell.Row - ActiveCell.Column = 3 Then
ActiveCell.Value = ""
Else
ActiveCell.Formula = "=vlookup(index(B5:AV51,row()-4,1),'[" & Range("B4").Value & ".xlsx]Sheet1'!A1:E70,5,false)"
End If
Next
Application.EnableEvents = True
End Sub