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