Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VBA Excel Chart

VBA Excel Chart

VBA Excel Chart

I have a chaert that is automatically produced by selecting a cell. It has worked for a year but now has failed

RE: VBA Excel Chart

I used the folowing code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'simple example of
' dynamically positioning chart and
' assigning values to a single series chart
'you must have a defined range of series names
' and a defined range for the columns containing the Values
'NOTE: Use the Watch Window or Object Browser to discover Object Properties

Dim iColCount As Integer

With Target.Parent.ChartObjects(1) 'the Target's Parent is the Worksheet
If Not Intersect(Target, [seriesnames]) Is Nothing Then 'only selection in the range
If Target.Count = 1 Then 'only if ONE cell selected
.Visible = True

With .Chart.ChartArea 'position chart
.Top = Target.Top + 30
.Left = Target.Left + Target.Width
End With

With .Chart.SeriesCollection(1) 'assign SeriesCol properties
iColCount = Target.Parent.UsedRange.Columns.Count
.Values = Intersect(Target.EntireRow, Range(Cells(1, 2), Cells(1, iColCount)).EntireColumn)
.Name = Target.Value
End With
End If
Else 'chart not visible
.Visible = False
End If
End With
End Sub

RE: VBA Excel Chart

Somehow, your procedure that I sent you went from 44 lines to 31?

And you failed to upload your workbook, both here and at Tek-Tips.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: VBA Excel Chart


I used my copy of your workbook from 27 Dec 21 19:15.

But if I paste in your code, I get a strange data shift.

Your code modification does not look at min and max values: mine does.

My code, which works perfectly on this workbook, changes the chart y-axis min & max to display the discrete y-values.

So why not tell us what you changed and why.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: VBA Excel Chart

Hey, Bill, did you get this sorted out?


glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close