|
献丑了,把目录改成个人电脑的目录。
Sub 多簿多表转置合一()
Application.ScreenUpdating = False
Dim FileName As String, DataWb As Workbook, DataSht As Worksheet, EndRow As Long, DataArr As Variant
Dim ToSht As Worksheet, ToRng As Range, i As Byte
FileName = Dir("C:\Users\Limonet\OneDrive\桌面\M函数各参数详解(Record类)\*.xlsx")
Do While FileName <> ""
i = i + 1
Range("A" & i + 1).Value = Mid(Replace(FileName, ".xlsx", ""), 5, 3) 'Replace此处是多余的
Workbooks.Open FileName:="C:\Users\Limonet\OneDrive\桌面\M函数各参数详解(Record类)\" & FileName
Set DataWb = ActiveWorkbook
For Each DataSht In Worksheets
EndRow = DataSht.Range("A1048576").End(xlUp).Row
DataArr = DataSht.Range("A1:A" & EndRow).Value
Set ToSht = ThisWorkbook.Worksheets(1)
Set ToRng = ToSht.Range("B1048576").End(xlUp).Offset(1, 0)
ToRng.Resize(1, UBound(DataArr, 1)).Value = Application.Transpose(DataArr)
Next DataSht
DataWb.Close savechanges:=False
FileName = Dir
Loop
Application.ScreenUpdating = True
End Sub
|
|