Could someone please point me in the right direction. I'm trying to cycle through open workbooks, when particular ones are found I want to use wb1 and ws1 for a specific worksheet to be used later.
Honestly, I'm not even sure if I'm explaining that correctly.
Honestly, I'm not even sure if I'm explaining that correctly.
VBA Code:
Private Sub test()
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lr1 As Long, lr2 As Long
For Each wb In Workbooks
If wb.Name Like "*Registration*" Then
wb1 = wb.Name
End If
If wb.Name Like "User_Report*" Then
wb2 = wb.Name
End If
Next
Set ws1 = wb1.Sheets("KPI Data")
Set ws2 = wb2.Sheets("Sheet0")
lr1 = ws1.Cells(ws1.Rows.Count, 1).End(xlUp).Row
lr2 = ws2.Cells(ws1.Rows.Count, 1).End(xlUp).Row
End Sub