VBA calculate sheet when opened

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hello all,

I have a workbook with many sheets and manual calculation is default by other VBA trigger.

I am in need of code that will calculate a sheet when it is opened and also other sheets that are linked to it as well.

Example:
I open sheet 1.
Sheet 1 calculates.
I also want sheets 3,5and 7 to calculate as well when sheet 1 is opened.

Your help is greatly appreciated!

Russ
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
After thinking about this further, I would like to calculate sheets when exiting a sheet.
This what I have tried:

Private Sub Worksheet_Deactivate()
ThisWorkbook.Sheets("Distro").Calculate
ThisWorkbook.Sheets("Multi Breakdown").Calculate
ThisWorkbook.Sheets("Assign Looms").Calculate
ThisWorkbook.Sheets("Locations").Calculate
ThisWorkbook.Sheets("Patch By Universe").Calculate
End Sub
 
Upvote 0
Code:
[COLOR=#333333]Private Sub Worksheet_Deactivate()[/COLOR]
[COLOR=#333333]Sheets("Distro").Calculate[/COLOR]
[COLOR=#333333]End Sub[/COLOR]

This works for me, are you putting the macro on the sheet or in a module?
 
Upvote 0
On the sheet.

I am getting this error:

Compile error:
Ambiguous name detected: Worksheet_Deactivate

I am also using other VBA on the sheet as well like:

Private Sub Worksheet_Deactivate()
ThisWorkbook.Sheets("Multi Build").Application.Calculation = xlManual
End Sub
 
Upvote 0
I'd say it's ambiguous as you're using the event multiple times.

Can you not put all the code in the one Sub?
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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