|
以下是一串代码,语句中的 Maxline 是什么意思
Private Sub CommandButton1_Click()
Dim My_Path As String
Dim My_Name As String
My_Path = ThisWorkbook.Path & "\" & Range("B1").Value
Maxline = 1
Application.ScreenUpdating = False
Worksheets("Data").Cells.ClearContents
myfileName = Dir(My_Path & "\*.csv")
Do While myfileName <> ""
'打开文件
Workbooks.Open My_Path & "\" & myfileName
With Workbooks(myfileName)
'Data extrct
If ThisWorkbook.Worksheets("Data").Range("A1") = "" Then
For i = 1 To .Worksheets(1).Range("IV1").End(xlToLeft).Column
ThisWorkbook.Worksheets("Data").Cells(Maxline, i).Value = .Worksheets(1).Cells(1, i).Value
ThisWorkbook.Worksheets("Data").Cells(Maxline + 1, i) = .Worksheets(1).Cells(2, i)
Next i
Maxline = 2
Else
For i = 1 To .Worksheets(1).Range("IV1").End(xlToLeft).Column
ThisWorkbook.Worksheets("Data").Cells(Maxline + 1, i) = .Worksheets(1).Cells(2, i)
Next i
Maxline = Maxline + 1
End If
End With
'关闭文件
Workbooks(myfileName).Close False
myfileName = Dir
Loop
Application.ScreenUpdating = True
End Sub
|
|