|
楼主 |
发表于 2013-4-9 10:27
|
显示全部楼层
open方法:
- Private Sub Worksheet_Change(ByVal Target As Range)
- Application.ScreenUpdating = False
- Application.EnableEvents = False
- If Target.Row <> 1 Or Target.Column <> 3 Then Exit Sub
- Dim i As Integer, j As Integer
- Dim wb As Workbook
- Dim sh As Worksheet
- Dim arr As Variant
- Dim brr(1 To 5) As Variant
- Set wb = Workbooks.Open(ThisWorkbook.Path & "\1.xlsx", , , , "123")
- Set sh = wb.Sheets("工作表1")
- j = sh.[a65536].End(xlUp).Row
- arr = sh.Range("a2:e" & j)
- For i = 1 To UBound(arr)
- If arr(i, 1) = Target.Value Then
- brr(1) = arr(i, 1)
- brr(2) = arr(i, 2)
- brr(3) = arr(i, 3)
- brr(4) = arr(i, 4)
- brr(5) = arr(i, 5)
- Exit For
- End If
- Next
- wb.Close True
- Range("a4").Resize(1, 5) = brr
- Application.EnableEvents = True
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|