Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Codes below try to check every existing workbook's name currently opened is correct and if not, it exit sub After several attempts, it still not able to run and prompts " Subscript out of range" Sub test() Dim y As Long, x As Variant x = Array("AB.xls", "CD.xls", "EF.xls", "GH.xls") For y = LBound(x) To UBound(x) If Workbooks(x(y)).Name = "AB.xls" Then MsgBox Workbooks(x(y)).Name & " not found " Exit Sub ElseIf Workbooks(x(y)).Name = "CD.xls" Then MsgBox Workbooks(x(y)).Name & " not found " Exit Sub ElseIf Workbooks(x(y)).Name = "EF.xls" Then MsgBox Workbooks(x(y)).Name & " not found " Exit Sub ElseIf Workbooks(x(y)).Name = "GH.xls" Then MsgBox Workbooks(x(y)).Name & " not found " Exit Sub End If Next y End Sub Any helps will be appreciated and thanks in advance Regards Len |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How To Check If The User Has Macros Enabled When The Workbook Opens | Excel Programming | |||
when opening an Excel Workbook, another blank workbook also opens | Excel Discussion (Misc queries) | |||
How to add a password check when an excel workbook opens? | Excel Programming | |||
Personal workbook opens when Excel opens | Excel Discussion (Misc queries) | |||
Check no. of records have copied correctly | Excel Programming |