Dynamic Chart Scale

B

BUDDY

I'm trying to embed an event procedure that changes the
point an axis crosses, based on a cell reference. Below
is the code. Below that is the error message I get.

Help?! TIA


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Address

Case "$Q$3"
ActiveSheet.ChartObjects("Chart 1").Chart.Axes
(xlCategory).CrossesAt = Target.Value
Case Else
End Select


End Sub




"Unable to get ChartObjects property of the Worksheet
class"
 
B

BUDDY

Thanks for the response. This is great for scaling, but I
would really like to have a dynamic "Crosses At" for each
axis... Any ideas?
 
K

Kevin Beckham

Try this fragment

With ActiveSheet.ChartObjects("Chart 1") _
.Chart.Axes(xlCategory)
.Crosses = xlCustom
.CrossesAt = Target.Value
End With


Kevin Beckham
 
J

Jon Peltier

Buddy -

The error message you posted means the code couldn't find the chart on
the worksheet. Probably you don't have a chart named "Chart 1". The rest
of the code works fine, if I have a chart with the right name.

To check or change the name of a chart, select a cell, then hold shift
while selecting the chart. This selects the chart object, not one of the
chart elements. It has little white handles instead of the black ones,
and there's a name in the name box (above the header for column A). Type
a name there that you want, and press Enter.

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top