Worksheet change detection for macro execution, skips one macro

SedrickBowser

New Member
Joined
Feb 6, 2019
Messages
1
Hey there!

I have a few various modules depending on a- I believe simple- worksheet change detection for their initiation. The problem is that the worksheet_change seems to constantly detect a change in two of macro initiation functions and it never acknowledges the third.

Heres the code:

Code:
Private Sub worksheet_change(ByVal target As Range)

Dim keycells As Range
Dim keycellsEF As Range
Dim keycellsDebt As Range

Set keycells = Me.Range("E36, E46, E53, E59, E67, E77, M35, M44")
Set keycellsEF = Me.Range("O7, P7")
Set keycellsDebt = Me.Range("G23")

If Application.Intersect(keycells, Range(target.Address)) _
Is Nothing Then
Call visual_aidFunds
End If

If Application.Intersect(keycellsEF, Range(target.Address)) _
Is Nothing Then
Call visual_aidEF
End If

If Application.Intersect(keycellsDebt, Range(target.Address)) _
Is Nothing Then
Call visual_aidDebt
End If
           
End Sub

What I have done to test the "flow" of the program is to place msgboxes at the beginning of each called modules. Visual_aidEF, with the use of keycellsEF, is the only one not triggered. What is weird, though, is that visual_aidEF will trigger if it replaces visual_aidDebt or visual_aidFunds.

One further test that I have done is that I have placed msgboxes to test the target.address at various points and have also msgboxed the three different keycell variables that I have created to see if that values align in that way-which they do.

That last that I'd like to say is that I'm not sure if my strategy to use individual If statements for each module is wise, but ElseIf refused to work and I don't believe that I can use a Case Select in this instance.

I'm wiling to believe that there is a much more practical solution that would resolve this weirdness, but I haven't been able to find the answer after quite a few hours of testing researching. Your consideration is much appreciated!

-Sedrick
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
The logic is like this: if the target intersection is in some keycells, that is, if it is not nothing, then call visual_aidFunds:

Code:
Private Sub worksheet_change(ByVal target As Range)


    Dim keycells As Range
    Dim keycellsEF As Range
    Dim keycellsDebt As Range
    
    Set keycells = Me.Range("E36, E46, E53, E59, E67, E77, M35, M44")
    Set keycellsEF = Me.Range("O7, P7")
    Set keycellsDebt = Me.Range("G23")
    
    If Not Intersect(target, keycells) Is Nothing Then
        Call visual_aidFunds
    End If
    
    If Not Intersect(target, keycellsEF) Is Nothing Then
        Call visual_aidEF
    End If
    
    If Not Intersect(target, keycellsDebt) Is Nothing Then
        Call visual_aidDebt
    End If
               
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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