+ Reply to Thread
Results 1 to 9 of 9

Interesting visualization idea

Hybrid View

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    50

    Interesting visualization idea

    So here is my idea, just wondering if it is possible.

    So say cell B1 has a value of 10. Now my idea is for cell B2 to have a marker that shows where the value of B1 falls on a scale.

    For instance:
    Capture.JPG
    (just so you can understand what im getting at)

    If this is at all possible I could apply it to a project I am currently working on. If not, it was a good idea

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Interesting visualization idea

    Dont see why you couldn't do that. Draw the shape/use a picture and then move it as neccessary. The minimum value would be:
    Range("B2").left
    and the maximum value would be
    Range("B2").left + Range("B2").width
    so the position of the centre of the slider would be
    Range("B2").left+((Range("B2").left+Range("B2").width)/20)*Range("B1").value
    I guess you would need to subtract half of the slider width and then assign that formula to the slider.left property (where slider is a variable assigned to your shape/picture)

  3. #3
    Registered User
    Join Date
    07-11-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Interesting visualization idea

    What would the code be to assign slider to the shape?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Interesting visualization idea

    Set Slider = Sheets("Sheet Name").Shapes("Shape Name")
    or you could use:
    Sheets("Sheet Name").Shapes("Shape Name").left = Range("B2").left+((Range("B2").left+Range("B2").width)/20)*Range("B1").value
    instead

  5. #5
    Registered User
    Join Date
    07-11-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Interesting visualization idea

    I have this

    slider = Sheets("Sheet1").Shapes("Flowchart: Sort 1")
    but I get the error "Object doesn't support this property or method"

    Sorry if I'm slow, never used excel shapes before

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Interesting visualization idea

    You need
    set slider = Sheets("Sheet1").shapes("Flowchart: Sort 1")

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Interesting visualization idea

    Try this, which goes in the worksheet module, which can be accessed by right clicking the worksheet tab and selecting View Code.
    
    Private Sub Worksheet_Change(ByVal Target As Range)
       If Target.Row = 1 And Target.Column = 2 Then
            Me.Shapes("FlowChart: Sort 1").Left = Target.Offset(1).Left + Target.Offset(1).Width / (Target.Offset(1, 1) - Target.Offset(1, -1)) * Target.Value
        End If
    End Sub
    It's only set up for B1/B2 but could be adapted if you have a row of these shapes as in the image.
    If posting code please use code tags, see here.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,444

    Re: Interesting visualization idea

    non coded approach.

    would need more work if the min/max values change radically
    Cheers
    Andy
    www.andypope.info

  9. #9
    Registered User
    Join Date
    07-11-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Interesting visualization idea

    Here is what I have come up with:

    Sub Macro1()
    
    Set slider = Sheets("Sheet1").Shapes("Flowchart: Sort 1")
    LeftPos = Range("F5").Left
    RightPos = Range("F5").Left + Range("F5").Width
    Value = Range("G3").Value
    If Value < Range("E5").Value Or Value > Range("G5").Value Then
        ActiveSheet.Shapes.Range(Array("Flowchart: Sort 1")).Select
        Selection.ShapeRange.Fill.Visible = msoFalse
        Selection.ShapeRange.Line.Visible = msoFalse
        GoTo EndSub
    Else
        ActiveSheet.Shapes.Range(Array("Flowchart: Sort 1")).Select
        With Selection.ShapeRange.Fill
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 0, 0)
            .Solid
        End With
        With Selection.ShapeRange.Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(255, 0, 0)
            .Transparency = 0
        End With
    End If
    Position = LeftPos + ((Value - Range("E5").Value) / (Range("G5").Value - Range("E5").Value)) * (RightPos - LeftPos)
    slider.Height = Range("F5").Height
    slider.Top = Range("F5").Top
    slider.Left = Position - (0.5 * slider.Width)
    EndSub:
    Range("G3").Select
    End Sub
    It is set to automatically run when G3 is selected. E5 and G5 are the min and max.

    Another cool idea would be to create a color gradient that changes the slider depending on position. I think this would be similar to finding the position but it seems a bit daunting for me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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