VBA code dissapeared!

Filip Vermote

New Member
Joined
Jan 24, 2019
Messages
7
Office Version
  1. 365
  2. 2021
  3. 2019
Yesterday I closed my .xlsm workbook without any remarks.
It contains a lot of macro's and settings.
However, by opening this morning I received a warning that the VBA-project cannot be found.
All the modules are there, but all the VBA code dissapeared!
These are the two warnings in attachment.
Can anyone help me? What happened?
 

Attachments

  • Warning2.JPG
    Warning2.JPG
    14.4 KB · Views: 7
  • Warning1.JPG
    Warning1.JPG
    21.6 KB · Views: 7

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
If everything you say is true, then it sounds to me like the most likely scenarios are either:
- the file has become corrupted
- it was saved in the wrong format (a format which does not allow VBA code)

Was the file saved with a "SaveAs" yesterday, where the file type may have been changed?

Hopefully, you have a good backup of the file that you can restore to.
 
Upvote 0
Thanks so much for you reply, the file is always saved the same way because it's also a macro which saves it.
I will try to recover it, I hope at least, I will inform you how this goes further!

Filip
 
Upvote 0
OK.
the file is always saved the same way because it's also a macro which saves it.
If you want to paste the section of the code that saves the file, we can review it to see if there are any obvious issues with it.
 
Upvote 0
This is the VBA-code:

Sub Sluitaf()

'Save macro

'---Setting the exact frame views

Application.ScreenUpdating = False
Sheets("Hoofdschakelbord").Visible = True
Application.Goto Reference:="Hoofdmenu"
ActiveWindow.Zoom = True
Sheets("Combolijst").Visible = False
Sheets("Grafiek").Visible = False
Sheets("Grafieken").Visible = False
Sheets("VSI-data").Visible = False
Sheets("Data").Visible = False
Sheets("Percentages").Visible = False

'--- saving HPU-tool

With ActiveWorkbook
.Save
.Close
End With
End Sub
 
Upvote 0
OK, it is not even doing a "SaveAs", just a "Save".
So I don't see any issue there.

Sounds like your file may have become corrupted.
 
Upvote 0
Maybe but the same file opens without problems on my colleague's laptop... Could it be excel itself that has a problem?
 
Upvote 0
So, it works on some computers, but not others?
And yuo can see the VBA code on the other computers, but not yours?

Have you checked/verified that the computer is set to allow VBA code (and not automatically disable it)?

If so, then it may be a matter of that installation of Excel being corrupted on that computer.
You may need to re-install it on that computer, and make sure that you have all the lastest patches and upgrades.
 
Upvote 0
That's what I also thought to do, after it's installed I will get you informed.
Thanks anyway for your help!
 
Upvote 0
You are welcome.

Best of luck!
I hope that fixes things for you.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top