But the file is not saving as Macro enabled
It shows the following Message
Errors were detecting while saving "Path & Filename". Microsoft Excel may be able to save the file by removing or repairing some features. To make the repairs in a new file, click Continue. To cancel the saving file, click Cancel.
Const ExpirationDate = #5/25/2015#
Const ExpirationDate = #25/5/2015#
Hello Muneeb,
Firstly I am surprised that Excel accepted the date in d/m/y format. My local date format is d/m/y and if I insert the date that way then it automatically changes it to m/d/y format if the day is greater than 12. If the day is not greater than 12 then I
finish up with the wrong date. If I enter the date as #25 May 2015# then it also changes the date to #5/25/2015#
I don't suppose you are attempting to insert this macro with the on-line version of Excel. I haven't tried creating a macro with it but to the best of my knowledge, it does not work.
The error message indicates to me that it cannot save the workbook as Macro enabled. This can occur if there is an error in the code that needs fixing before saving. Try inserting the following line at the very top of the page in the VBA editor. (Before
the Const declarations.)
Option Explicit
After you have inserted the above line, click on menu item Debug then Compile VBA Project. If Compile VBA Project is disabled (Greyed out) then at some place in the code insert a blank line so the Excel thinks you have made a change. (To do this, position
the cursor at the end of a line and press Enter.) and then Select Debug -> Compile VBA Project.
When the code is compiled, if there is a problem in the code that will prevent saving then the debugger will stop on the line and highlight it.
If this does not work then can you upload a copy of the workbook for me.
Guidelines to upload a workbook on OneDrive:
- Zip your workbooks. Do not just save to OneDrive because the workbooks open with On-Line Excel and the limited functionality with the On-Line version causes problems.
- To Zip a file: In Windows Explorer Right click on the selected file and select Send to -> Compressed (zipped) folder.)
- Do not use 3rd party compression applications because I cannot unzip them. I do not clog up my computer with 3rd party apps when there are perfectly good apps supplied with windows.
- Go to this link. https://onedrive.live.com
- Use the same login Id and Password that you use for this forum.
- Select Upload in the blue bar across the top and browse to the zipped folder to be uploaded.
- Select Open (or just double click). (Be patient and give it time to display the file after initially seeing the popup indicating it is done.)
- Right click the file on OneDrive and select Share.
- Do NOT fill in the form; Select "Get a Link" on the left side.
- Click the button "Create a Link"
- Click in the box where the link is created and it will highlight.
- Copy the link and paste into your reply on this forum.