Number of VBA statistics files _vba

Source: Internet
Author: User

Description

1 The first sheet named Sheet1, and the second named step
22 sheet comparison, if the same, put the number of files in the second column of Sheet1

Sub countstep () ' Countstep Macro ' keyboard shortcut:ctrl+shift+t Dim sheetycnt As Integer Dim stepycnt As Integer Dim sheetname As String Dim stepname As String sheetname = "Sheet1" ' result page name stepname = ' Step ' result from Pag E Name sheetycnt = Worksheets (sheetname). UsedRange.Rows.Count stepycnt = Worksheets (stepname). UsedRange.Rows.Count for i = 1 to sheetycnt Dim fileName as String ' read ' column 1 of the result page filename = Worksheets (sheetname). Cells (i, 1). Value Dim k as Integer k = 0 for j = 1 to stepycnt Dim fullName As String Dim lastword As Stri Ng Dim Index as Integer fullName = Worksheets (stepname). Cells (J, 1). Value ' read column 1 of result from page ' substr String from last ' \ ' to end index = InStrRev (FullName, "
            \ ") Lastword = Mid (fullName, index + 1) If FileName = Lastword Then k = k + 1 ' Column 5 (result from page)-> column 1 (Result page) worksheets (sheetname). Cells (i, 2).


 Value = K End If Next next MsgBox ' End ' End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.