Only want this macro to run when column A cells 4-13 are selected

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
I have this macro that run anytime the sheet has a change done to it,
however I'd prefer if it only ran anytime Column A cells 4 to 13 were selected
(that's any one of the cells, not all the cells together.)

please can someone show me how to amend it, or what I need to do?

this is the macro:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).MinimumScale = Range("e25")
    ActiveChart.Axes(xlValue).MaximumScale = Range("d25")
   
End Sub



thanks

Tony
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Tony,

Try...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("A4:A13")) Is Nothing Then Exit Sub


   ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).MinimumScale = Range("e25")
    ActiveChart.Axes(xlValue).MaximumScale = Range("d25")
   
End Sub

Hope that helps.
 
Upvote 0
Hi Snakehips,
Wow, that works perfectly,
big thank you
and on a Saturday!

Tony
 
Upvote 0
Don't forget that I charge double on a Saturday!
And then of course, there will be the +25% 'works perfectly' supplement.
Please advise postal address for invoice.
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

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