Dim file As String
Private Sub openfile(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
opennextfile
End If
End Sub
Sub opennextfile()
With Application.FileDialog(msoFileDialogOpen)
.Filters.Add "Excel Files", "*.xls, *.xlsx"
If .Show = True Then
FileCount = .SelectedItems.Count
Filename = .SelectedItems(1)
Range("D2").Value = Filename
file = Filename
openrealy
End If
End With
End Sub
Sub openrealy()
Workbooks.Open (file)
With ActiveWorkbook
Dim i As Integer
For i = 2 To 10
Sheet1.Range("A" & i) = .Sheets(1).Range("A" & i).Value
Next
.Close
End With
End Sub
标签:VBA,End,Sub,excel,Filename,Range,file,取得 From: https://www.cnblogs.com/dzh1990/p/4538057.html