I have code that runs a report for work. It starts with finding the workbook to activate and then run the report on that wb. This method works most of the time, but I just realized that there are WAY too many workbook name possibilities for this method to be dependable everyday and the name is constantly changing.
How do I add a "file picker" so as soon as I click on the userform button it requires you to select a file to run the report on?
BTW, I have a variable called My_downloads that I would like the file to be picked from
Thanks.
How do I add a "file picker" so as soon as I click on the userform button it requires you to select a file to run the report on?
BTW, I have a variable called My_downloads that I would like the file to be picked from
Thanks.
VBA Code:
Private Sub CommandButton27_Click()
CommandButton27.BackColor = RGB(0, 100, 0)
Dim My_Workbook As Workbook
Dim wb As Workbook
Dim df As Folder
Dim FileName As String, FileName2, FileName3, FileName4, F1, F2, F3, F4 As String
Dim WBFound As Boolean
FileName = FullDate & "ED Restrictions Voids*.xlsx"
FileName2 = FullDate & " EDRestrictions Voids*.xlsx"
FileName3 = FullDate3 & "ED A Share Restrictions Voids*.xlsx"
FileName4 = FullDate3 & " ED A Share Restrictions Voids*.xlsx"
'***********************************************************
' Find and activate workbook file to activate and run macro
' - look in open workbooks and downloads folder
'***********************************************************
WBFound = False
For Each wb In Application.Workbooks
If wb.Name Like FileName Or wb.Name Like FileName2 Or _
wb.Name Like FileName3 Or wb.Name Like FileName4 Then
WBFound = True
wb.Activate
Call UBT_Combo_P1
CommandButton27.Enabled = False
End If
Next wb