change macro only runs when I move cursor up page

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
79
I've inserted the code below,

I change the value in cell F9, which should trigger the second sub below
I hit enter and my cursor goes to F10. Macro doesn't give expected result.
I hit enter a few more times and cursor continues down the page. No expected result.
I click those cells moving back up the page. nothing changes
When I click back onto cell F9 where I originally made the change, NOW I get the intended result.

I thought that as soon as made the change to F9 I should get that result. I don't know why I have to make the change in F9, click to another cell, and then click back to F9 to get the result.

Any help is appreciated.


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)




If Not Intersect(Target, Range("F6:F8")) Is Nothing Then
Call ApprVal
End If
Debug.Print "Updated Appr Value"








If Not Intersect(Target, Range("F8:F9")) Is Nothing Then
Call StateChanges
End If
Debug.Print "State Changed"












End Sub
This is the sub it calls

Code:
Sub PA_Drivers()
With Sheets("Drivers")
    Cells(10, 6).Value = 0.01
       
End With


End Sub
 
Last edited:

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,761
Office Version
2013
Platform
Windows
You should not need to do things like this:
Tell us what your ultimate goal is.

When you click on a cell in the range what do you want to happen?
You should not need to call another script.

Is
Drivers
The sheet with the selection change script?
 
Last edited:

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
79
You should not need to do things like this:
Tell us what your ultimate goal is.

When you click on a cell in the range what do you want to happen?
You should not need to call another script.

Is
Drivers
The sheet with the selection change script?
I Understand there are different ways to do this, and I'm definitely open to alternate ways to handle. I was just trying to understand what is causing the behavior that I described. Any thoughts on what is causing that?

As far as what I'm trying to do, its in the macro that I'm calling.
If State = PA, then set cell(10,6)= .01

Sub PA_Drivers()
With Sheets("Drivers")
Cells(10, 6).Value = 0.01
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,626
Office Version
365
Platform
Windows
Your code is a SelectionChange event, it should be a Change event.
Also it is not calling the PA_Drivers sub
 

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
79
This was so helpful to me. I just realized I never responded. Once I broke through that silly little problem I was off to the races. Great learning experience here. I really appreciate the support!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,626
Office Version
365
Platform
Windows
Glad we could help & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,099,029
Messages
5,466,116
Members
406,468
Latest member
Toto Li

This Week's Hot Topics

Top