Private Sub Worksheet_Change(ByVal Target As Range)
For I = 9 To 15
If cell(I, 10).Value <> "" Then
Dim Wb As Workbook
Dim Temp As String
Application.ScreenUpdating = False
Temp = "C:\Users\Administrator\Desktop\采购单\"&cell(i,10).value&".xls"
Set Wb = GetObject(Temp)
With Wb.Sheets(1).Range("A1").CurrentRegion
Range("A1").Resize(.Rows.Count, .Columns.Count) = .Value
Wb.Close False
End With
Set Wb = Nothing
Application.ScreenUpdating = True
End If
Next
End Sub
这里我想用变量作为文件名,总是出错Temp = "C:\Users\Administrator\Desktop\采购单\"&cell(i,10).value&".xls"
For I = 9 To 15
If cell(I, 10).Value <> "" Then
Dim Wb As Workbook
Dim Temp As String
Application.ScreenUpdating = False
Temp = "C:\Users\Administrator\Desktop\采购单\"&cell(i,10).value&".xls"
Set Wb = GetObject(Temp)
With Wb.Sheets(1).Range("A1").CurrentRegion
Range("A1").Resize(.Rows.Count, .Columns.Count) = .Value
Wb.Close False
End With
Set Wb = Nothing
Application.ScreenUpdating = True
End If
Next
End Sub
这里我想用变量作为文件名,总是出错Temp = "C:\Users\Administrator\Desktop\采购单\"&cell(i,10).value&".xls"