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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

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,143,917
Messages
5,721,529
Members
422,369
Latest member
redinator

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