Sub Open_Peru201_Sheet()
'
' Open Peru2011 Sheet Macro
' Macro recorded 07/06/2008 by home
'
Dim wbPeruMoney As Workbook
Dim wbPeruMoney_Open As Boolean
Dim wbPeruMoneyString As String
wbPeruMoney_Open = False
wbPeruMoneyString = "C:\Documents and Settings\home\My Documents\My accounts 08\Money for Peru 2011.xls"
For Each wbPeruMoney In Application.Workbooks
If wb.Name = wbPeruMoneyString Then
wbPeruMoney_Open = True
wb.Activate
MsgBox "Workbook is open!"
End If
Next
If wbPeruMoney_Open = False Then
Workbooks.Open wbPeruMoneyString
MsgBox "Workbook is open!"
End If
End Sub
I go to Peru occasionally. I'm developing a spreadsheet to monitor my savings for each vist. So, I've compiled this VBA code to allow my program to check whether the worksheet is open or not when I press the activate button. However, I'm having problem with the line below. Can anybody offer suggestions for overcoming this problem please?
If wb.Name = wbPeruMoneyString Then
I think the wb.Name must by a system variable, because I haven't created it anywhere.
Tags: