VBA BeforeSave Macro

KLUBKHTY

New Member
Joined
Oct 23, 2002
Messages
3
Hi, I am new to VBA coding and I need some help.

I wrote a macro and named it Chart.
I want to have my Chart macro run anytime a user goes to save the file and I want the "Chart" changes to be saved also. I don't know how to write the code to make this happen. I've testing several ways and when I hit the save button, it never works, the macro does not run. Any help is appreciated.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Asala42

Well-known Member
Joined
Feb 26, 2002
Messages
2,318
It sounds like you're trying to apply a Workbook_BeforeSave Event.

In the VB Editor (specifically the Project Explorer Window), enter the following code in the "ThisWorkbook" section.

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Call chart
End Sub

HTH
 

KLUBKHTY

New Member
Joined
Oct 23, 2002
Messages
3
Asala,

You are great!!!
I had that code before, just in the wrong section (as a Module). Thank you so much!
 

Forum statistics

Threads
1,181,461
Messages
5,930,067
Members
436,718
Latest member
messa57fr

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
Top