|
有好东西大家分享,一般不要设密码,有缺陷可以共同探讨。- Sub 获取数据()
- Dim myf, spath, fs, f, fc, myname, myrow, mycolumn
- spath = ""
- Application.FileDialog(msoFileDialogFolderPicker).InitialFileName = spath
- With Application.FileDialog(msoFileDialogFolderPicker)
- .ButtonName = "Yes"
- If .Show = True Then
- spath = .SelectedItems(1)
- Else: Exit Sub
- End If
- End With
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set f = fs.GetFolder(spath)
- Set fc = f.Files
- For Each myf In fc
-
- Workbooks.Open (myf)
- With myf
- myname = myf.Name
- Application.Workbooks(myname).Worksheets("产品销售明细表").Activate
- With Sheets("产品销售明细表")
- myrow = Range("A65536").End(xlUp).Row
- mycolumn = Range("XFD1").End(xlToLeft).Column
- Range(Cells(1, 6), Cells(myrow, mycolumn)).Select
- Selection.Copy
- End With
- Application.Windows("利润分析.xlsm").Activate
- With Workbooks("利润分析.xlsm")
- .Worksheets("销售明细表").Range("A" & Range("A65536").End(xlUp).Row).Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
- End With
- End With
- Application.Windows(myname).Activate
- Application.CutCopyMode = False
- ActiveWindow.Close False
- Next
- End Sub
复制代码 |
|