Macros A and B both run correctly separately, but macroB doesn't work when called after macroA in ThisWorkbook.
Hope my question is clear.
Thanks.
macroA:
macroB:HTML Code:
HTML Code:
ThisWorkbook:
HTML Code:
Macros A and B both run correctly separately, but macroB doesn't work when called after macroA in ThisWorkbook.
Hope my question is clear.
Thanks.
macroA:
macroB:HTML Code:
HTML Code:
ThisWorkbook:
HTML Code:
Last edited by EEEHHH; 09-04-2021 at 11:10 AM.
Please explain what "doesn't work" means.
- Does the code run?
- Does it run but do nothing?
- Does it produce error messages? If so, what do the messages say?
- Does it produce unexpected/wrong results? If so, how do the results differ from what you expect?
- Does it hang?
There is only two minutes during each day when macroB will do anything. Are you opening the file during those two minutes?![]()
Please Login or Register to view this content.
Does the code run?
Yes, but macroB does not create new workbook.
Does it run but do nothing?
Everything else runs as expected except there is no output/result from macroB.
Does it produce error messages? If so, what do the messages say?
No error messege.
Does it produce unexpected/wrong results? If so, how do the results differ from what you expect?
Expecting a new workbook to be created, but it does not happen.
Does it hang?
No.
Explanation:-
After opening the workbook:
macroA: works fine and as expected every one minute populates sheet4 with data till 11:00:00.
macroB: is expected to create a new workbook, copy sheet4 from old workbook to new workbook thereafter name, save and close the new workbook in a given folder. This is expected to happen between 11:12:00 to 11:14:00.
But macroB does not give any result. No new workbook is created.
ThisWorkbook ("SaveExit"): At 11:15:00 the old workbook is saved and closed, this part also works fine.
macroA works fine, macroB ( skips ?) finally the old workbook gets saved and closed at 11:15:00.
NB: Running macroB individually (F5) works fine and creates a new workbook as expected.
Last edited by EEEHHH; 09-05-2021 at 05:57 AM.
Old workbook is already open and gets closed at 11:15:00.
New workbook is not created so can't open it.
Let me explain this a different way.
Your top-level sub Workbook_Open will run exactly once, when the workbook containing this code is first opened.
First Workbook_Open calls macroA. macroA sets up a timer to call itself back a minute later, then goes and does some other stuff. None of this has anything to do with macroB.
Then Workbook_Open calls macroB. So macroB is called only once, when the file is first opened. The first thing macroB does is check the current time. If it is before 11:12 or after 11:14, then macroB immediately quits. You are giving it only one chance to do this, when the first is first opened. If you open the file at any other time macroB will do nothing. That sounds like what you are seeing.
I can help you fix this but I don't understand the big picture of what you want this whole system to do so I can't tell you how to fix it.
Hi,
Basically macroA collects data from web and populates sheet4 till 11:00:00. I want this data to be stored in new workbook everyday after 11:00:00. Thereafter data from sheet4 of old workbook is cleared. Old and new workbook is closed. Next day old workbook is opened and it starts collecting data afresh and then new workbook is created etc and so on. So the old workbook creates a new workbook with data for each day with timestamp.
Based on your comment I added 1min timer in macroB, which seemed to work but new problems cropped up like multiple prompts asking to save file / file already exist etc, eventually whole workbook got deleted !
Will retry and revert.HTML Code:
Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks