Private Sub Worksheet_Calculate() is not private?

spacely

Board Regular
Joined
Oct 26, 2007
Messages
248
Hi,

I have a workbook/sheet that has a callback on Calculation associated with it:

Private Sub Worksheet_Calculate()

But whenever it is opened in the same workBOOK as anothe excel application, changes in the other excel sheets/book actually trigger this callback. Why is that?

Baffled,
Dave
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
No. There is only 1 sheet in that book. Is there a way to specify the sheet name that is being recalculated? I have the code in the Sheet code:

Private Sub Worksheet_Calculate()
ScrollBar13.Max = Int(Worksheets("static clear").Cells(2, 23).Value)
End Sub
 
Upvote 0
That procedure is in the worksheet's module, so there is no need to specify its name. The procedure will fire only when that particular worksheet is calculated.

By the way, if there is only one worksheet what is Worksheets("static clear")?
 
Upvote 0
That's the name of the single worksheet. I am just changing a scrollbar's max value which is in a cell of that sheet.

Is it all coded right? Maybe an Excel bug?
 
Upvote 0
If it's the same sheet, then you can use:
Code:
Private Sub Worksheet_Calculate()
ScrollBar13.Max = Int(Me.Cells(2, 23).Value)
End Sub
whether it's a bug or not, I can't say as I don't know what is in the sheet that might cause it to recalculate.<!-- / message -->
 
Upvote 0
The weird thing is changes in another book (opened in the same Instance of Excel) trigger the Calculate callback in that sheet belonging to a different book.
 
Upvote 0
That's not necessarily weird - depends what is in your sheet. Probably one or more volatile functions
 
Upvote 0
I'm having the same problem.

I have a workbook with 3 worksheets and have used Private Sub worksheet_calculate. When I open another workbook along side this one, when ever I change something in the unrelated workbook, it produces an error for the worksheet_calculate that is contained within the first workbook. Why is this happening? There is nothing linking them. It happens when any other workbook is open alongside.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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