Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 8th, 2003, 01:44 PM
rothss rothss is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 rothss User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Macros

I am trying to change the color of graphs depending on the values being graphed (In other words, some graphs will have yellow lines, some red, and some green.) How do I run a macro automatically based on a certain condition? Is there a way to name my macros, so I can put an IF statement in and run from there? I have tried conditional formatting, but it doesn't work with graphs (or I haven't figured it out yet.). I can get my data to change colors using this, but am stuck. Any ideas would be greatly appreciated. Thanks.

Reply With Quote
  #2  
Old July 14th, 2003, 03:30 AM
CraigMcKee CraigMcKee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: England
Posts: 2 CraigMcKee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Code like this would work:

Sub Macro1()

Range("A1").select
Select Case Activecell.value

Case is < 5
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Interior
.ColorIndex = 5
.Pattern = xlSolid
End With
Application.CommandBars("Chart").Visible = False

Case is < 10
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With
Application.CommandBars("Chart").Visible = False

Case is <20
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Application.CommandBars("Chart").Visible = False

End Select

End Sub

Obviously you will need to change the cell where the macro starts adn the ranges but that's the general gist.

The easiest way I think to find out the colour indexs' is just to record a macro and change the colour of something then you will see what the colour index is when you go into VB.

Craig

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Macros


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway