A user of my macro can have multiple files open. For three of these files I know roughly what these files will be called, but as the name changes slightly each time the macro is run, I need to use variables when working with the files.
I've found an old thread that used this code:
I have attempted to adapt it as follows:
When I hover over w.Name, the code has successfully identified the correct file, but neither of my attempts above at setting the ExpReport variable to the workbook name are working.
How can I set ExpReport to something useful, so in further code I can just refer to it like LastRow = ExpReport.ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
I've found an old thread that used this code:
VBA Code:
Sub test()
For Each w In Workbooks
If w.Name Like "*View Repair Inspection*" Then
Windows(w.Name).Activate
Exit For
End If
Next w
End Sub
I have attempted to adapt it as follows:
VBA Code:
Dim w As Workbook, ExpReport As Workbook, Xero As Workbook, TypeReport As Workbook
For Each w In Workbooks
If w.Name Like "*Exportier*" Then
ExpReport = Windows(w.Name).Name
ExpReport = w.Name
Exit For
End If
Next w
How can I set ExpReport to something useful, so in further code I can just refer to it like LastRow = ExpReport.ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row