vba Change Macro not firing consistantly

Jesienouski

New Member
Joined
Mar 9, 2011
Messages
14
First post, so be kind. I have a change macro within a large workbook that is not firing consistantly. The change will fire the first time the workbook is opened and the change takes place, but then stops working after that. Does anyone know what is going on? I can send the workbook if needed, but it is almost 6 megs. I'm working in '07 if that helps too.
 
Do you have a form called frmCalendar4?
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Yes, and it's identical to frmCalendar3 which is working except for the range it looks at.
Code:
Private Sub Calendar4_Click()
    Sheet28.Select
    Sheet28.Range("H9").Value = Calendar4.Value
    Unload Me
    Sheet28.Range("H9").Select
End Sub
Private Sub cmdClose_Click()
    Unload Me
    Sheet28.Range("H9").Select
End Sub
Private Sub UserForm_Initialize()
    If IsDate(Range("H9").Value) Then
        Calendar4.Value = DateValue(ActiveCell.Value)
    Else
        Calendar4.Value = Date
    End If
End Sub
 
Upvote 0
Comment out the On Error Goto err_handler line in the Change event code (just put an apostrophe in front of it) then change the value in H9. When the error message pops up, press f8 to step through the code line by line until an error occurs and tell me which line it occurs on.
 
Upvote 0
It errors on the UserForm_Initialize Sub after the Else, it runs down and when it gets to Calendar4.Value = Date it errors. What's weird is that is the exact same code as the other calendars I have

Code:
Private Sub UserForm_Initialize()
    If IsDate(Range("H9").Value) Then
        Calendar4.Value = DateValue(ActiveCell.Value)
    Else
        Calendar4.Value = Date
    End If
End Sub
 
Upvote 0
Do you have a calendar control on that form that is called Calendar4? (doesn't sound like it)
 
Upvote 0

Forum statistics

Threads
1,214,895
Messages
6,122,128
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top