change macro only runs when I move cursor up page

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
82
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:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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:
Upvote 0
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
 
Upvote 0
Your code is a SelectionChange event, it should be a Change event.
Also it is not calling the PA_Drivers sub
 
Upvote 0
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!
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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