zoukankan      html  css  js  c++  java
  • 如何用VBA代码依次打开文件夹下的Excel文件

    'Check Public Function Check() As Variant On Error GoTo erlb      Dim StrDir As String    StrDir = ThisWorkbook.Worksheets("Path").Range("B2")     objfile = Dir(StrDir & "*.xlsx")    ThisWorkbook.Worksheets("Result").Activate      With ActiveSheet       .Range("A2:B400").Select       ' .Cells.Select        Selection.ClearContents        .Range("A1").Select  End With      Application.ScreenUpdating = False    Do While objfile <> ""      Workbooks.Open StrDir & "" & objfile          ' Workbooks(objfile).Activate      ActiveWorkbook.Worksheets("Sheet1").Activate           maxRow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row

         iCnt = 0      startRow = 9           With ActiveSheet         For iRow = startRow To maxRow             If Trim(ActiveSheet.Cells(iRow, 1)) <> "" Then                If Trim(ActiveSheet.Cells(iRow, 2)) = "" Then                     iCnt = iCnt + 1                End If             Else                Exit For             End If         Next      End With           Workbooks(objfile).Activate           'Workbooks(objfile).Close          ActiveWorkbook.Close           With ThisWorkbook.Worksheets("結果")          resultmaxRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row          .Cells(resultmaxRow + 1, 1) = objfile          .Cells(resultmaxRow + 1, 2) = iCnt      End With           objfile = Dir        Loop     Application.ScreenUpdating = True      MsgBox "計算完了"      Exit Function   erlb:

      MsgBox Err.Number & Err.Description  End Function        

  • 相关阅读:
    查看DNS、IP、Mac等
    windows测试物理网络
    ACCEPT详解
    oracle动静视图-权限-角色-参数
    [ PHP+jQuery ] ajax 多级联动菜单的应用:电商网站的用户地址选择功能 ( 二 )
    使用Python爬取网页的相关内容(图片,文字,链接等等)
    使用Python爬取网页的相关内容(图片,文字,链接等等)
    使用Pycharm安装插件时发生错误
    使用Pycharm安装插件时发生错误
    使用Pycharm安装插件时发生错误
  • 原文地址:https://www.cnblogs.com/mochaMM/p/4764218.html
Copyright © 2011-2022 走看看