|
这个代码可以直接取你想取的数,前提是你要提取数的工作薄中的表已经全部设置了打印区域。
Sub JL()
Dim Arr, ArrJG()
Dim PathName$, dirna
Application.ScreenUpdating = False
column1 = Range("IV2").End(xlToLeft).Column
Range(Range("A2"), Cells(65536, column1)).ClearContents
K = 1
PathName = ThisWorkbook.Path & "\*.xls"
dirna = Dir(PathName)
Do While dirna <> ""
If dirna <> ActiveWorkbook.Name Then
Set App = Application
Set SourceBook = App.Workbooks.Open(ThisWorkbook.Path & "\" & dirna, 0, True)
Set Sourcesheet = SourceBook.Worksheets("3")
h = Split(dirna, ".")(0)
j = 0
With Sourcesheet
Arr = .Range("Q10:Q" & Split(.PageSetup.PrintArea, "$")(4))
End With
SourceBook.Close False
For i = 1 To UBound(Arr)
If Arr(i, 1) <> "" Then
j = j + 1
ReDim Preserve ArrJG(1 To j)
ArrJG(j) = Arr(i, 1)
End If
Next i
Cells(2, K) = h
Cells(3, K).Resize(j) = Application.Transpose(ArrJG)
K = K + 1
Erase Arr
End If
dirna = Dir
Loop
Application.ScreenUpdating = True
End Sub
|
|