I have an excel vba problem that I am trying to solve and after scouring the internet and many forums, i have been unsuccessful.
question 1: Is it possible to open file BrianJohnson.xlsx if the cell in a2 says Brian Johnson (or even BrianJohnson)? there will be about 30 files that I would like to open like this so the master file can use cell references in other sheets and things will not get screwy.
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
Compiled but not tested…