Hi,
I have a code that looks for an open workbook that contains a certain string in the name. Sometimes this workbook maybe called something random. Can i add to the code so of the wb cant be found then it will prompt me to manually choose a workbook that is currently open?
Below is the code to look for the open workbook
Thank in advance
Blunder
I have a code that looks for an open workbook that contains a certain string in the name. Sometimes this workbook maybe called something random. Can i add to the code so of the wb cant be found then it will prompt me to manually choose a workbook that is currently open?
Below is the code to look for the open workbook
Code:
Private Function SelectWB(ByVal strName As String, ByRef wbSelected As Excel.Workbook) As Boolean
Dim wb As Excel.Workbook
For Each wb In Application.Workbooks
If InStr(wb.Name, strName) > 0 Then
Set wbSelected = wb
SelectWB = True
Exit Function
End If
Next
End Function
Application.ActiveSheet.Shapes("button 85").Delete
Sub WB()
wbList = Array("AES")
For iTemp = 0 To UBound(wbList)
If SelectWB(wbList(iTemp), wbSelected) Then
wbSelected.Activate
End If
Next
End Sub
Thank in advance
Blunder