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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0
Asala,

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

Forum statistics

Threads
1,214,549
Messages
6,120,149
Members
448,948
Latest member
spamiki

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