我有一个我正在尝试解决的 excel vba 问题,在搜索了互联网和许多论坛之后,我一直没有成功。
问题1:如果a2中的单元格显示Brian Johnson(甚至BrianJohnson),是否可以打开文件BrianJohnson.xlsx?将有大约 30 个文件我想像这样打开这样主文件可以使用其他工作表中的单元格引用,并且事情不会变得混乱。
Sub aaron_gather()
'
' aaron_gather Macro
Dim bestandopen
Application.ScreenUpdating = False
On Error Resume Next 'if there are no 12 sheets
bestandopen = Dir("H:\Americorps\*")
Do Until bestandopen = ""
If bestandopen = "" Then Exit Do
If Not bestandopen = "Americorps Master Sheet 1.xlsm" Then
Workbooks.Open "H:\Americorps\" & bestandopen
ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Offset(1) = ActiveWorkbook.Name
For i = 1 To 12
ThisWorkbook.Sheets("Total Hours").Cells(Rows.Count, 1).End(xlUp).Offset(, i) = ActiveWorkbook.Sheets(i).Range("E43")
Next i
ThisWorkbook.Sheets("Total Hours").Columns.AutoFit
Workbooks(bestandopen).Close
End If
bestandopen = Dir
Loop
End Sub