![]() |
Help 'splain unusual behavior in simple procedure
Hi,
I have a module in a workbook. There is a Sub Main() procedure in that module that simply calls other procedures. It started out like this: Sub Main() Call Proc1 End Sub Sub Proc1() 'Run some code. End Sub I have a macro that runs overnight, which opens the workbook and runs Sub Main. It's all been working fine for about a week. Then I added to it to make it look something like: Sub Main() Call Proc1 If Weekday(Date) = 2 Then Call Proc2 End Sub Sub Proc1() 'Run some code. End Sub Sub Proc2() 'Run some other code. End Sub The idea is that the second procedure should only run on Monday. However, I was seeing unexpected results when I came in the next day. So I stepped through Sub Main. It totally skipped the first line and went directly to the If Weekday.... statement. I took out the Call and stepped through. It worked the way I wanted. It went to Proc1, ran that code, then came back and ran through the rest of Sub Main. What's going on, can anyone tell me? tod |
All times are GMT +1. The time now is 11:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com