Help VBA Me.Calculate

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
OK so here is the scenario

smart alec me decides the auto calc function makes the workbook way to slow

so I make the Workbook manual on startup
Add this to the from of my code
Rich (BB code):
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Rich (BB code):

some code here
Rich (BB code):
me.calculate
Rich (BB code):

a bit more code
Rich (BB code):
Application.EnableEvents = True 
Application.ScreenUpdating = True 
Application.DisplayAlerts = True


but it seems that the me.calculate does not work whilst the application.x = False

is there a way around or am I missing something

Martin

 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi AlphaFrog

Ok, I use
Rich (BB code):

Sheets("Data").Select
just prior to the me.calculate

when I step through the code using F8 it works
but not when left to run

I will try some of the other methods in your link as I only need to calculate 5 out of the 20 columns

Am I wrong in thinking ME is the active sheet at time of reaching line of code

Martin
 
Upvote 0
...Am I wrong in thinking ME is the active sheet at time of reaching line of code

Martin

I am presuming that Me.Calculate is in a worksheet's module, as I don't believe that calculate will aim at a specific workbook. If that is the case, Me.Calculate should calculate the worksheet that the code resides in, regardless of what sheet is active. In short, Me is aimed at the object it resides in, like ThisWorkbook refers to the workbook it resides in.

Hope that helps,

Mark
 
Upvote 0
Ahhh

OK I get it,

I have just been fortunate that all my previous work has followed this rule:

this time I just got bit unfortunate :eek:(

this was my code, just so someone else does not make the same mistake..

WRONG USE OF ME Keyword
Rich (BB code):
Private Sub CommandButton1_Click()

Sheets("EPOS1").Activate
Me.Calculate

Sheets("EPOS2").Activate
Me.Calculate

Sheets("Pivots (£)").Activate
Sheets("Pivots (u)").Activate
Sheets("Pivots (w)").Activate

Sheets("Market.Share (3)").Activate
Me.Calculate

Sheets("Market.Share (2)").Activate
Me.Calculate

Sheets("Market.Share").Activate
Me.Calculate

End Sub

Changed to this, no need to activate the sheet
Rich (BB code):
Private Sub CommandButton1_Click()

Sheets("EPOS1").Calculate
Sheets("EPOS2").Calculate

 
     'Pivot sheets have On Activation code to set up all the PAGEFIELDS
Sheets("Pivots (£)").Activate
Sheets("Pivots (u)").Activate
Sheets("Pivots (w)").Activate

Sheets("Market.Share").Calculate
Sheets("Market.Share (2)").Calculate
Sheets("Market.Share (3)").Calculate

Sheets("Market.Share").Activate
End Sub


Thanks for your help guys, especially for the links

Martin
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,284
Members
448,885
Latest member
LokiSonic

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