mkvarious

New Member
Joined
Jan 24, 2013
Messages
44
hello,

I am trying to write a code that fires when user filters data.
I have tried using Workbook_SheetCalculate in the ThisWorkbook module but although I first have Application.EvanbleEvents=False line then macro still fires twice.
This is really strange as on many threads I have read this is supposed to work?[\color]

Code:
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Application.EnableEvents = False
Set Sh = Sheets("TT_forecast tab")
If Sh.FilterMode = True Then
    MsgBox "tak!"
End If
Application.EnableEvents = True
End Sub
[\code]
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
What's this?

Code:
Set Sh = Sheets("TT_forecast tab")

Sh has already been passed to the procedure (the sheet that is being calculated). Maybe you need worksheet level code rather than workbook level code (in the module for 'TT_forecast tab').
 
Upvote 0
hello Andrew,

this to pass to excel what sheet is to be checked in the procedure as I do not want the same happening for all the sheets/tabs.
Code:
Set Sh = Sheets("TT_forecast tab")

My conclusion is that is must have been some macro error yesterday as when I tried the same code today it is working, both in the ThisWorkook and Worksheet level code and in both cases messege box only pops up, once.
thanks for your help, anyway.

Code:
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Application.EnableEvents = False
Set Sh = Sheets("TT_forecast tab")
If Sh.FilterMode = True Then
    MsgBox "tak!"
End If
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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