Hello everybody, a question about Macros recover.

I have a file that i ran some macro on it, i had the function on a text file but it has been deleted, so i just need to get the macro back, i still have the file that i ran the function on it but when i go to the macros by typing Alt+F8 the list is empty, i try to create a function in order to get into Microsoft Visual Basic window (when i put the function on the first place) and search there to see if the function i saved somewhere but it didnt... is there anyway that i can find the function from the file that i ran the function on it? like history that keeps the all macros that used on the file or somthing like that?

Thnks everyone...

 

 

Question Info


Last updated October 11, 2018 Views 12,852 Applies to:
Answer

One more thing to add at this point:  macros are not saved when you save a file in .csv format.  The .csv format is essentially a plain text file that can even be opened, read and edited with a text editing program like Notepad or Wordpad.

To save an Excel file with its macros in Excel 2007, you must save it as an .xlsm file at least once, and that is the file you would find the macro in.  After having saved it as an .xlsm file you could then safely save it in another format such as .csv.


I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein
I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Answer

The .xlsx files won't have the macro in them - if you save a file with macros in it as a .xlsx file, Excel throws the macro(s) away before saving it.  Let's say you start a new workbook and put a macro into it and then you save the file as a .xlsx file: you should be alerted that the "VB Project" is not saved in .xlsx files and that if you want to save the macros (which are within the VB Project of the workbook) then you need to Save As and choose macro enabled workbook (.xlsm).  The macro will remain within the workbook after saving as a .xlsx file until you close it, but when you open the .xlsx file later, the macro will not be there.

You might try searching your D: drive or even your entire Computer for *.xlsm files and see if any of them contain the lost macro.  I sincerely wish you luck in finding a file with the macro in it.

The VB Editor does not keep track of macros that have been run.  A simple explanation of the typical situation is that while the VB Editor is part of Excel, the VB Project is part of a workbook.  Each workbook has it's own VB Project with macros for that workbook contained within it.  I say this is a simple explanation because there are ways of having macros in one workbook and using them to process information in other workbooks, but typically the macros used in a workbook are part of that workbook.

For any given workbook, you can press [Alt]+[F8] to see a list of all available macros in it and you can press [Alt]+[F11] to open the VB Editor and view the code in the VB Project for that workbook.  Also, if you press [Alt]+[F8] and highlight a macro name and then click the [Edit] button, the VB Editor will be opened showing you the code for that particular macro.  That might help you also.  If you find the code inside of a file and use [Alt]+[F8] along with [Edit] to view it, you can copy it and paste it into a text file, say a Notepad file, and save the code as a text file for use again later as you did before in another workbook .


I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein
I am free because I know that I alone am morally responsible for everything I do. R.A. Heinlein

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.