VBA Open Excel file traverse sheet name and value of the specified cell

Source: Internet
Author: User

Today, there is an application on the project, get the name of all sheet under the specified Excel file and the value of the specified cell in the current sheet, and write them to the fixed sheet, see, the file is more, and the number of each file sheet more, also different, So I intend to write a program to help us achieve the task, the code is very simple, but also written more rigid. We welcome your comments and your code:

SubAAAA ()DimSH1, SH2 asWorksheetDimShname, Cellvalue as String'On Error Resume NextSetSH1 = Workbooks (1). Sheets (1)'workbooks.open filename:= "d:\_jack\finance report\report layout\ta Opex report 2014.xlsx"Workbooks.Open filename:="d:\_jack\finance report\report layout\rolling PL Template v1 (2). xlsx" fori =1  toWorkbooks (2). Worksheets.count Workbooks (2). ActivateSetSH2 =activeworkbook.worksheets (i) sh2. Activate N=SH2. Name'v = sh2. Cells (5, 7). Value ' G5 cellv = sh2. Cells (4,3). Value'C4 CellWorkbooks (1). Activate SH1. Activate SH1. Cells (i,1) =N SH1. Cells (i,2) =vNextWorkbooks (2). CloseEnd Sub  


Copyright: The above code is developed by me, the copyright belongs to http://www.cnblogs.com/mq0036 personal. If used for non-commercial purposes, you can freely reprint, reproduced please specify the source.

VBA Open Excel file traverse sheet name and value of the specified cell

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.