still learning
Well-known Member
- Joined
- Jan 15, 2010
- Messages
- 858
- Office Version
- 365
- Platform
- Windows
Hi
Sorry that's it a long question but I wanted to explain what I tried.
I made a calendar years ago and have the dates formatted as “D”
I use the following macro when I open the workbook (I added enableEvents thinking it would help. And left it in.)
I also have it in the sheet when I go to a different sheet and come back
This is the macro I’m trying to run
What happens is when I first open excel and go the workbook, I works fine.
When I’m done added events to the calendar, I save and close the workbook.
If I go back to it after a few minutes, the sheet opens but the macro doesn’t do any thing
I changed the macro at the end to open a message box to see it will work. But i get the same results. I got an error message that I need “End If” and added that, to the revised macro.
I then put it in a new workbook/sheet with a cell that has today’s date and it works good, I save and closed the workbook and go back to it a few minutes later, and it does nothing.
To make sure my syntax is correct, I put this macro in the new sheet and works fine.
I save and close and it. After a few minutes, I open it and run the macro and it works.
I ranged name the cell with today’s date and made a macro to go to that range name and it works when the other macro doesn’t. ( in the new sheet)
If I close excel completely and start it again, these macros work fine. Then after a few minutes it doesn’t
I have no problem with any other macros in the same Calander workbook/sheets
Its been working fine for a couple of years till about January of this year.
mike
Sorry that's it a long question but I wanted to explain what I tried.
I made a calendar years ago and have the dates formatted as “D”
I use the following macro when I open the workbook (I added enableEvents thinking it would help. And left it in.)
VBA Code:
Private Sub Workbook_open()
Application.enableevents = True
gotodateday
End Sub
VBA Code:
Private Sub Worksheet_activate()
Application.enableevents = True
gotodateday
End Sub
VBA Code:
Sub gotodateday()
Dim C As Range
Set C = Range("B1:O1300").Find(Date)
If Not C Is Nothing Then C.Select
End Sub
When I’m done added events to the calendar, I save and close the workbook.
If I go back to it after a few minutes, the sheet opens but the macro doesn’t do any thing
I changed the macro at the end to open a message box to see it will work. But i get the same results. I got an error message that I need “End If” and added that, to the revised macro.
VBA Code:
Sub gotodateday()
Dim C As Range
Set C = Range("B1:O1300").Find(Date)
'If Not C Is Nothing Then C.Select
If Not C Is Nothing Then
msgbox ("no date")
End If
End Sub
To make sure my syntax is correct, I put this macro in the new sheet and works fine.
I save and close and it. After a few minutes, I open it and run the macro and it works.
VBA Code:
Sub test()
msgbox ("no date")
End Sub
If I close excel completely and start it again, these macros work fine. Then after a few minutes it doesn’t
I have no problem with any other macros in the same Calander workbook/sheets
Its been working fine for a couple of years till about January of this year.
mike