+ Reply to Thread
Results 1 to 9 of 9

Drawing a line on a sheet based off cell value

  1. #1
    Forum Contributor
    Join Date
    03-28-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    166

    Drawing a line on a sheet based off cell value

    Hello,

    So I am trying to plot a line on a user designed graph depending on a cell's value. I did not use the chart wizard to do this because I have to use the user designed graph. So it would be like a median or average line if I was using the chart wizard.

    I have included what the file and based off the value in AG36 is where the orange line is needed.

    So I know Vba will draw a line with a statement like Call DrawArrows(Range("B25"), range("AF25"), RGB(0,0,255), "Line")

    Any ideas will be helpful.

    LeapingLizard
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Drawing a line on a sheet based off cell value

    Hello
    Maybe a Conditional Formatting formula applied to B2:AF28:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Format the fill to required colour.

    DBY

  3. #3
    Forum Contributor
    Join Date
    03-28-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    166

    Re: Drawing a line on a sheet based off cell value

    Hello DBY,

    This worked as it just highlighted the cells. Was looking for code that would input a line. I just don't know how to have this statement; Call DrawArrows(Range("B25"), range("AF25"), RGB(0,0,255), "Line") call the ranges out as the could change each time. I appreciate the thought. Any other suggestions would be appreciated.

    LeapingLizard

  4. #4
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Drawing a line on a sheet based off cell value

    Sorry I misunderstood. I don't know about the 'DrawArrows' call but try the following VBA code on the Worksheet Calculate Event:

    Please Login or Register  to view this content.
    Does this do as you require?

  5. #5
    Forum Contributor
    Join Date
    03-28-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    166

    Re: Drawing a line on a sheet based off cell value(solved)

    Super! Your help is greatly appreciated.

  6. #6
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Drawing a line on a sheet based off cell value

    Glad to have helped. Thank you for the feedback.

  7. #7
    Forum Contributor
    Join Date
    03-28-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    166

    Re: Drawing a line on a sheet based off cell value

    Hello DBY,

    It worked, but did not plot in the proper location. Plus, when does this sub routine run? I have included the updated file and you will be able to see the discrepancy. Thanks!

    LeapingLizard
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Drawing a line on a sheet based off cell value

    Hello
    You need to put the code into the Worksheet's (Cleanliness Audits) Calculate Event, not into a Module has you have done. In the VBA editor, double click the Sheet name and from the two dropdowns in the code window select 'Worksheet' and 'Calculate'. I've adjusted the code slightly:

    Please Login or Register  to view this content.
    However, the line will go to the first number above, so 91 for example, the line will be at 95 as it's greater than 90. Is that correct?

    *Note I should have mentioned. When this macro fires after a sheet calculation, the Undo facility will not be available. One of the drawbacks in using VBA, I'm afraid.
    Last edited by DBY; 09-19-2016 at 03:08 PM.

  9. #9
    Forum Contributor
    Join Date
    03-28-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    166

    Re: Drawing a line on a sheet based off cell value

    Thank you! Yes you are correct as long as it plots correctly. Thanks so much! Solved
    I added to your reputation.
    Last edited by LeapingLizard; 09-19-2016 at 04:04 PM. Reason: Solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy Cell info in a Sheet, to another area, based what the text line starts with?
    By richard11153 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-08-2016, 05:16 PM
  2. Drawing a line on all column
    By bbke in forum Excel General
    Replies: 1
    Last Post: 04-07-2015, 12:40 PM
  3. Modify (conditional format) a Drawing Object based on cell value
    By osmosis in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-28-2012, 11:57 AM
  4. Line Drawing gives Doulble Line
    By Hercules1946 in forum Excel General
    Replies: 3
    Last Post: 11-04-2012, 08:15 AM
  5. [SOLVED] Drawing a line in bar chart
    By Julien in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-06-2006, 06:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1