Dear Friends,
I want the macro to run once daily when the workbook is open, no matter what time it is. The format of date should be 'dd mm yyyy'.
Please correct my code to run a macro once a day.
Thanking you in anticipation.
Mukesh
Dear Friends,
I want the macro to run once daily when the workbook is open, no matter what time it is. The format of date should be 'dd mm yyyy'.
Please correct my code to run a macro once a day.
Thanking you in anticipation.
Mukesh
Using B2 Cell as Helper cell
![]()
Please Login or Register to view this content.
If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
Mark your thread as Solved
If the suggestion helps you, then Click *below to Add Reputation
Hi, Mukesh ,
a different approach which will store the last date the macro was run in a Name and compare that value on opening with the actual date to decide whether to run the macro or not.
ThisWorkbook:
Module1:![]()
Please Login or Register to view this content.
Ciao,![]()
Please Login or Register to view this content.
Holger
Use Code-Tags for showing your code: [code] Your Code here [/code]
Please mark your question Solved if there has been offered a solution that works fine for you
Good morning Sixthsense ,
Thank you for solution. I am learning a lot of macro coding from you experts. It's working fine but I didn't understand the logic behind this code so that I can use it in my other files also. I tried to use it in my file by changing some code but it's not working. Please tell me the logic behind it to use it by myself in other programs easily.
I'm attaching a sample file for your reference.
Do guide me to write such code independently in future.
Thank you.
Mukesh
Good morning HaHoBe,
Excellent! It's a new approach. It's working fine but I want to learn the code so that I can use it in other files independently. Please explain me how to use this code in other files and what change is required. That means by simply changing few lines it's applicable for all files.
The code is very complicated so I didn't understand it but it's working fine.
Thank you for solution. Please refer my attached file and guide me how to use it in that file. I'm learning a lot of macro codes from this forum and you experts.
Thank you.
Mukesh
Hi, Mukesh,
most of what the code does is written in the comments to the Workbook_Open. So in order for the example to work the name should be listed in the names of the workbook and filled with a serial value less than today, the Workbook_Open-code must be placed in ThisWorkbook, the function to check whether the name is listed in the Names has to be placed in a standard module, and the name of the procedure to run has to be amended to suit and that procedure should be placed in a standard procedure as well.
Ciao,
Holger
Good morning Sixthsense ,,
I tried to use your suggestion in my file but it is giving error 1004. Please correct my error and guide me how to avoide this error in future. Plese se the attached file.
Mukesh
Good morning HaHoBe,
Thank you for your guidance. Your code is very difficult for me to understand. Do compile it in my file attached and I will try to learn what change you have made to work it correctly. Also give some tips to understand it better.
What is a meaning of 'holger' which is at the bottom of your mail. Is it a German word? It's just for curiosity only.
Thanking you in anticipation.
Mukesh
Hi, Mukesh ,
I psoted the code as well where that code is supposed to go. You would need to alter the code line in Workbook_Open-code
to suit to your needs and make sure that this macro mentioned there is known for Excel VBA in the workbook (declare it as a Public Sub in a standard module).![]()
Please Login or Register to view this content.
Any standard module must hold the Function used in order to work.
If you save that workbook after inserting the codes and open it again the date to check will be the same as the one stored in the Name (unless you change it to say =41450 (Date of 25.06.2013) as opposed to show =41451 (Date of 26.06.2013)). So if no change has been made to the date on opening no execution of the macro code to call will be done. There isnīt even the need to implement the Name in the workbook as the Workbook_Open-event will do that if the name isnīt found.
If you want the code to work on the first opening after implementation as well please change the code line
to![]()
Please Login or Register to view this content.
in order to insert yesterdayīs date there.![]()
Please Login or Register to view this content.
Isnīt that a post as opposed to a mail?What is a meaning of 'holger' which is at the bottom of your mail.Itīs my FirstName.
Ciao,
Holger
Good morning Holger,
Thank you for your guidance. I will go through it and create a macro.
Thank you once again.
Mukesh
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks