Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
 
Posts: n/a
Default Autoshape in Chart controlled from a different worksheet

Hi all,

Can somebody please help.. i have a Chart (called Chart2 - on its own
page) and i have the data (sheet1) on another page.... i am trying to
get the autoshape in Chart2 to change colour based on the data from a
cell on Sheet1.

i have the following code....

i can get the shape to change colours on Sheet1, but, when i try it on
Chart2 nothing happens.

NB: this code is in Sheet1

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myColor As Long
Dim myShape As Shape

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("G119")) Is Nothing Then Exit Sub

Set myShape = Worksheets("Chart2").Shapes("Oval 1035")

Select Case LCase(Target.Value)
Case Is "1": myColor = 53
Case Is < "1": myColor = 33
Case Is = "1": myColor = 25
Case Else
myColor = 0
End Select

If myColor = 0 Then
myShape.Fill.Visible = False

Else
With myShape.Fill
.Visible = True
.ForeColor.SchemeColor = myColor
End With
End If


End Sub

Any help WHAT so ever would be greatly appreciated...

Many thanks

Paul

  #2   Report Post  
Posted to microsoft.public.excel.charting
Andy Pope
 
Posts: n/a
Default Autoshape in Chart controlled from a different worksheet

Hi Paul,

The reason it worked on a Worksheet was that you had an explicit
reference to the Worksheets object even though you where using the
chartsheets name. See comment in code.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim myColor As Long
Dim myShape As Shape

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("G119")) Is Nothing Then Exit Sub

' chart object not worksheet
Set myShape = Charts("Chart2").Shapes("Oval 1035")

' non textual comparison
Select Case Target.Value
Case Is 1: myColor = 53
Case Is < 1: myColor = 33
Case Is = 1: myColor = 25
Case Else
myColor = 0
End Select
If myColor = 0 Then
myShape.Fill.Visible = False

Else
With myShape.Fill
.Visible = True
.ForeColor.SchemeColor = myColor
End With
End If

End Sub

Cheers
Andy

wrote:
Hi all,

Can somebody please help.. i have a Chart (called Chart2 - on its own
page) and i have the data (sheet1) on another page.... i am trying to
get the autoshape in Chart2 to change colour based on the data from a
cell on Sheet1.

i have the following code....

i can get the shape to change colours on Sheet1, but, when i try it on
Chart2 nothing happens.

NB: this code is in Sheet1

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myColor As Long
Dim myShape As Shape

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("G119")) Is Nothing Then Exit Sub

Set myShape = Worksheets("Chart2").Shapes("Oval 1035")

Select Case LCase(Target.Value)
Case Is "1": myColor = 53
Case Is < "1": myColor = 33
Case Is = "1": myColor = 25
Case Else
myColor = 0
End Select

If myColor = 0 Then
myShape.Fill.Visible = False

Else
With myShape.Fill
.Visible = True
.ForeColor.SchemeColor = myColor
End With
End If


End Sub

Any help WHAT so ever would be greatly appreciated...

Many thanks

Paul


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.charting
 
Posts: n/a
Default Autoshape in Chart controlled from a different worksheet

EXCELLENT!!!

Thats exactly what i needed... many many many thanks....

cheers

Paul

  #4   Report Post  
Posted to microsoft.public.excel.charting
 
Posts: n/a
Default Autoshape in Chart controlled from a different worksheet

EXCELLENT!!!

Thats exactly what i needed... many many many thanks....

cheers

Paul

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How To: Link worksheet data to pre-existing chart tables Fitz Excel Discussion (Misc queries) 4 October 24th 05 11:05 PM
advanced: synchronizing data value across two worksheet drop boxes mdhokie Excel Worksheet Functions 1 October 6th 05 08:46 PM
Pie chart on a pie chart (exploded)? KR Excel Discussion (Misc queries) 1 June 9th 05 07:28 PM
Scrollbar on Chart Jumps to Left when Chart is Clicked Bob Charts and Charting in Excel 5 May 1st 05 02:06 AM
How can I show data under a Chart that I inserted in a worksheet? Kimo Charts and Charting in Excel 1 February 21st 05 04:11 PM


All times are GMT +1. The time now is 11:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"