May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.
Option Explicit Dim Monitored Private Sub Worksheet_Activate() Monitored = Range("A76").Value 'Read in value prior to any changes End Sub Sub newScale() Dim PriYMin As Integer Dim PriYMax As Integer Dim SecYMin As Integer Dim SecYMax As Integer PriYMin = 0 PriYMax = Range("A76").Value SecYMin = 0 SecYMax = Range("A76").Value Worksheets("Ressource Data").ChartObjects(1).Activate 'Charts("Charts1").Activate If ActiveChart Is Nothing Then MsgBox "Please select the chart to modify first." Exit Sub End If 'With ActiveChart.Axes(xlCategory) '.MinimumScale = [xMin] '.CrossesAt = [xMin] '.MaximumScale = [xMax] 'End With With ActiveChart.Axes(xlValue) .MinimumScale = [PriYMin] .CrossesAt = [PriYMin] .MaximumScale = [PriYMax] End With With ActiveChart.Axes(xlValue, xlSecondary) .MinimumScale = [SecYMin] .CrossesAt = [SecYMin] .MaximumScale = [SecYMax] End With 'PriYMin = the minimum value I need on the primary y-axis 'PriYMax = the maximum value I need on the primary y-axis 'SecYMin = the minimum value I need on the secondary y-axis 'SecYMax = the maximum value I need on the secondary y-axis End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'Prevent looping of code due to worksheet changes Application.EnableEvents = False 'Compare monitored cell with initial value If Range("E8").Value <> Monitored Then 'Do things as a result of a change Call newScale 'Reset Variable with new monitored value Monitored = Range("A76").Value End If 'Reset events Application.EnableEvents = True End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Populate Excel combo box with dependent vlookup||5||45|
|Excel Macro: Correct Macro that creates tabs for each "AccountSku"||4||37|
|Excel 2016 - Add-In giving Error 91 Object Variable not Set when opening a New Workbook||12||30|
|Need VBA to color cell if 1st three numbers in Column C of Sheet1 match any of the numbers in Column A on Sheet2||22||36|
Join the community of 500,000 technology professionals and ask your questions.