View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Private Sub Worksheet_change ... Procedures jamming up

Hi

First test if any of the target cells have been changed, second I
would set EnableEvents = False at the begininng of the macro and then
reset it at the end.


Try if this will do it:

Private Sub Worksheet_Change(ByVal Target As Range)
Call Method
Application.EnableEvents = False

Select Case Target.Address
'ALL
Case Is = Range("FlushBins").Address
If Range("FlushBins") = 1 Then
'The following calls all five ranges
Call FLBIN_ALL_H
ElseIf Range("FlushBins") = 0 Then
Call FLBIN_ALL_UH
End If

' # 1
Case Is = Range("FBSMINT").Address
If Range("FBSMINT") = 1 Then
' The following Calls to hide range 2 thru 5
Call FLBIN_SMI_H
ElseIf Range("FBSMINT") = 0 Then
' The following Calls the OTHER FOUR Ranges
Call FLBIN_SMI_UH
End If

' # 2
Case Is = Range("FBSAINT").Address
If Range("FBSAINT") = 1 Then
' The following Calls to hide Ranges 1, 3 - 5
Call FLBIN_SAI_H
ElseIf Range("FBSAINT") = 0 Then
Call FLBIN_SAI_UH
End If

' # 3
Case Is = Range("FBPART_EXT").Address
If Range("FBPART_EXT") = 1 Then
' The following Calls to HIDE Ranges 1, 2, 4, 5
Call FLBIN_Part_ExtLid_H
ElseIf Range("FBPART_EXT") = 0 Then
Call FLBIN_Part_ExtLid_UH
End If

' # 4
Case Is = Range("FBPART_INT").Address
If Range("FBPART_INT") = 1 Then
' The following Calls to Hide Ranges 1 - 3, 5
Call FLBIN_Part_IntLid_H
ElseIf Range("FBPART_INT") = 0 Then
Call FLBIN_Part_IntLid_UH
End If

' # 5
Case Is = Range("FBEXTMNT").Address
If Range("FBEXTMNT") = 1 Then
' The following Calls to Hide Ranges 1 - 4.
Call FLBIN_M_ExtMnt_H
ElseIf Range("FBEXTMNT") = 0 Then
Call FLBIN_M_ExtMnt_UH
End If
End Select
Application.EnableEvents = True
End Sub

Regards,
Per

On 23 Okt., 18:23, BEEJAY wrote:
Still trying to figure this out.
For purposes of this question "active" means NOT commented out.

There are 5 named "Trigger" Cells and 5 named Ranges.
Trigger Cell "X" is to Hide ALL 5 of the named Ranges.
Trigger Cell "1", is to hide Named Ranges 2 thru 5
Trigger Cell "2" is to *hide Named Ranges 1, and 3 thru 5.
etc...............

Problem: When only ONE (ANY one) of the "groupings" is Not Commented Out,
it works great!!!
When *the "ALL" group and # 1 Group are Active
* *Select Trigger Cell for "ALL" - Nothing seems to Happen
* *Select Trigger Cell for # 1 - It only Hides Group 5, NOT 2 thru 5

When Groups "ALL, # 1 and # 2" are active
* *Select Trigger Cell for "ALL" - Nothing Seems to Happen
* *Select Trigger Cell for #1 - Nothing Seems to Happen
* *Select Trigger Cell for # 2 - It only Hides Group Range 5, *NOT 1, 3 to 5.
etc..............
Again - each one on their own works as intended.

'BY CALL METHOD
'ALL
* * Application.EnableEvents = False
* * * * If Range("FlushBins") = 1 Then
'The following calls all five ranges
* * * * Call FLBIN_ALL_H
* * Else
* * If Range("FlushBins") = 0 Then
* * * * Call FLBIN_ALL_UH
* * * * End If
* *End If
* *Application.EnableEvents = True

' # 1
* * Application.EnableEvents = False
* * * *If Range("FBSMINT") = 1 Then
' The following Calls to hide range 2 thru 5
* * * * Call FLBIN_SMI_H
* * Else
* * If Range("FBSMINT") = 0 Then
' The following Calls the OTHER FOUR Ranges
* * * *Call FLBIN_SMI_UH
* * * *End If
* * End If
* * Application.EnableEvents = True

' # 2
' * * * *If Range("FBSAINT") = 1 Then
' The following Calls to hide Ranges 1, 3 - 5
' * * * Call FLBIN_SAI_H
' * *Else
' * *If Range("FBSAINT") = 0 Then
' * * * Call FLBIN_SAI_UH
' * * * End If
' * *End If
' * *Application.EnableEvents = True

' # 3
' * *Application.EnableEvents = False
' * *If Range("FBPART_EXT") = 1 Then
' The following Calls to HIDE Ranges 1, 2, 4, 5
' * * * Call FLBIN_Part_ExtLid_H
' * *Else
' * *If Range("FBPART_EXT") = 0 Then
' * * * Call FLBIN_Part_ExtLid_UH
' * * * End If
' * *End If
' * *Application.EnableEvents = True

' # 4
' * *Application.EnableEvents = False
' * *If Range("FBPART_INT") = 1 Then
' The following Calls to Hide Ranges 1 - 3, 5
' * * * *Call FLBIN_Part_IntLid_H
' * *Else
' * *If Range("FBPART_INT") = 0 Then
' * * * *Call FLBIN_Part_IntLid_UH
' * * * *End If
' * *End If
' * *Application.EnableEvents = True

' # 5
* * Application.EnableEvents = False
* * If Range("FBEXTMNT") = 1 Then
' The following Calls to Hide Ranges 1 - 4.
* * * * Call FLBIN_M_ExtMnt_H
* * Else
* * If Range("FBEXTMNT") = 0 Then
* * * * Call FLBIN_M_ExtMnt_UH
* * * * End If
* * End If
* * Application.EnableEvents = True

My module "layout" is as follows:
I have a std. module I called Range_Groupings:
Sample:

Sub FB_SMI_H()
* * * * Range("FBSMINT_S").EntireRow.Hidden = True
End Sub
Sub FB_SMI_UH()
* * * * Range("FBSMINT_S").EntireRow.Hidden = False
End Sub
etc............................

I have a module I've named CALLS
sample
Sub FLBIN_ALL_H()
' * Flush Bins - ALL
' * ALL to be Hidden
* * * * Call FB_SMI_H
* * * * Call FB_SAI_H
* * * * Call FB_Part_MIMEL_H
* * * * Call FB_Part_MIMIL_H
* * * * Call FB_MEXM_H
End Sub

Sub FLBIN_ALL_UH()
' * Flush Bins - ALL
' * ALL to be UN-Hidden
* * * * Call FB_SMI_UH
* * * * Call FB_SAI_UH
* * * * Call FB_Part_MIMEL_UH
* * * * Call FB_Part_MIMIL_UH
* * * * Call FB_MEXM_UH
End Sub
ETC.........................

So:
My worksheet module makes ONE Call of my "CALL" module, which CALLS as many
Ranges as required from my "Range_Grouping" module.
This "layout" seems to give me good oversight and control of my project.
HOWEVER:
When the project doesn't work as intended, it is not of much use.

I did try moving the enableEvents true false statements around, but with no
sucess.
I am now officially desperate.
Help please ???