Private Sub Worksheet_Change(ByVal Target As Range)
Dim wb As Workbook, sh, a, m, r
If Target.Column = 7 Then
Set wb = GetObject(ThisWorkbook.Path & "\B.xlsx")
Set sh = wb.Worksheets(1)
a = Target.Value
Set m = sh.Range("D:D").Find(What:=a, LookAt:=xlWhole)
If m Is Nothing Then
Target.Font.ColorIndex = 3
Else
Target.Font.ColorIndex = xlAutomatic
wb.Close
End If
End If
End Sub
Sub YANG()
Workbooks.Open ThisWorkbook.Path & "\NIDA.xlsx" '打开同目录下文件
Sheets("②Count Table").Range("A5:KH1500").Copy Workbooks("NIDA.xlsm").Sheets("②Count Table").Range("A5:A5:KH1500") '拷贝数据
ActiveWorkbook.Close = True '关闭A.xlsx
End Sub
里面的错误在 Range("A5:A5:KH1500") '拷贝数据
应该是 Range("A5:KH1500") '拷贝数据