Home » 文章 » 电脑技术 » Excel » 提取同一文件夹下各EXCEL工作薄中指定单元格的内容

提取同一文件夹下各EXCEL工作薄中指定单元格的内容

提取同一文件夹下各EXCEL工作薄中指定单元格的内容代码如下:

Sub test()
Dim xlapp As New Application
Dim mfile As String
Set xlapp = New Application
mfile = Dir(ThisWorkbook.Path & “\*.xls*”)
Do Until mfile = “”
Set wbk = xlapp.Workbooks.Open(ThisWorkbook.Path & “” & mfile)
i = i + 1
ThisWorkbook.Sheets(1).Cells(i, 1) = wbk.Sheets(1).Cells(25, “g”)
ThisWorkbook.Sheets(1).Cells(i, 2) = wbk.Sheets(1).Cells(12, “w”)
Set wbk = Nothing
mfile = Dir
Loop
End Sub

微信 OR 支付宝 扫描二维码
为博主 打个赏
pay_weixinpay_zhifubao
金额随意 快来“打”我呀~

3 comments

  1. 阅读博客获得的进步不亚于阅读一本书。

  2. 不止一次的来,不止一次的去,来来去去,这就是这个博客的魅力!

  3. 学海无涯,博客有道!拜读咯!

Leave a Reply

Your email address will not be published. Required fields are marked *

*