LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to prevent routine from running on certain sheets

Jim,

This solves the problem! Thank you.

Gary

"Jim Rech" wrote in message
...
I didn't try to run your code but it looks to me that the problem may be
that the formatting is done to the "activesheet". The sheet deactivate
event runs after you've left a sheet. So another sheet is therefore
active.
You're formatting the new sheet, not the old one.

I'd try passing the sheet to Calc_New_Expenses like :

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)

If Sh.Name = "Construction Expenses" Or Sh.Name = "Misc Expenses" Then
Calc_New_Expenses Sh
End If

End Sub


Sub Calc_New_Expenses(Sh as Worksheet)
Dim MyRange As Range, MyRows As Integer, ThisRow As Integer
''other code

With Sh
Set MyRange = .UsedRange
MyRows = MyRange.Rows.Count
'etc
End With

End Sub

Jim Rech
Excel MVP




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If I have my sheets protected will that prevent me running a macro to hide certain sells? Marc Excel Worksheet Functions 0 May 17th 06 11:36 PM
routine to refresh all pivots in WB acroos several sheets Todd F. Excel Discussion (Misc queries) 2 August 17th 05 12:56 PM
Prevent A Macro From Running If SpreadSheet is Filtered carl Excel Worksheet Functions 1 June 22nd 05 04:04 PM
Prevent running macro upon closing Excel Deneb Excel Programming 2 February 2nd 05 06:07 PM
Prevent users from running macros Alan Hutchins Excel Programming 7 June 2nd 04 05:12 PM


All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"