Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    i AM DOING A LITTLE DEMOSTARTION USING EXCEL. BASICALLY I HAVE 2 OPTIONS TO PICK FROM AND DEPENDING ON THE OPTIONS A DIFFERENT PICTURE will be displayed

    I HAVE 4 PICTURES,
    pic 1
    pic 2
    pic 3
    pic 4

    i have a drop down menu and checkbox option,

    i am not sure what kind of code i would need to show a picture is a condtion is met.

    pic 1 shows if ComboBox1 = Tubing w/Packer and checkbox1 is clicked on else hide
    pic 2 shows if ComboBox1 = tubing else hide
    pic 3 shows if ComboBox1 = Annulus else hide
    pic 4 shows if ComboBox1 = manifold else hide

    is there a easy way of hidding and showing the pictures based on conditions.
    I was thinking that the pictures could overlay each other and the one that meets the condition will be shown or brought to the front??

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXC

    Hi

    Here is an example that was floating around the Lounge a few months back. Is this the kind of thing you were looking for? It uses named ranges
    Jerry

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    If I understand what you are after:
    If you right click the combobox and select view code, you get to the sheet object. Add this code there

    <pre>Private Sub ComboBox1_Change()
    Dim x As Integer
    For x = 1 To 4
    Me.Shapes("pic " & x).Visible = False
    Next
    On Error Resume Next
    x = Application.WorksheetFunction. _
    Match(ComboBox1.Value, Me.Range("modelist"), 0)
    On Error GoTo 0
    If x > 1 Then
    Me.Shapes("pic " & x - 1).Visible = True
    End If
    End Sub</pre>


    It hides all the pics, then unhides the one selected. You can put the overlay the pics so they all show up at the same place.

    Steve

  4. #4
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXC

    this is short of what I am after I was hoping to have code behide each picture which decides to hide or show the pictrue
    is this possible?

  5. #5
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    Thanks Steve

    is there a way to incorperate the checkbox in this?

  6. #6
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXC

    I have gone off line since your responses from Steve but I have modified my example to fit your without code... hope it is useful
    Jerry

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    I would presume YES, but I am not sure what the checkbox is supposed to do...

    Could you elaborate?

    Steve

  8. #8
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    Ah, an idea. Is this what you are after?
    <pre>Private Sub CheckBox1_Click()
    If Not Me.CheckBox1.Value Then
    Me.Shapes("pic 4").Visible = False
    ElseIf Me.ComboBox1.Value = "Tubing w/Packer" Then
    Me.Shapes("pic 4").Visible = True
    End If
    End Sub

    Private Sub ComboBox1_Change()
    Dim x As Integer
    For x = 1 To 4
    Me.Shapes("pic " & x).Visible = False
    Next
    On Error Resume Next
    x = Application.WorksheetFunction. _
    Match(ComboBox1.Value, Me.Range("modelist"), 0)
    On Error GoTo 0
    If x > 1 Then
    Me.Shapes("pic " & x - 1).Visible = True
    End If
    If Not Me.CheckBox1.Value Then
    Me.Shapes("pic 4").Visible = False
    End If
    End Sub</pre>


    Or do you want the combobox to have only 4 items (eliminating "Tubing w/Packer") and have "packer" checkbox only toggle pic 3/4 when tubing is pressed and do nothing when when None, 1, or 2 is selected. The code could be adapted to do this...

    Steve

  9. #9
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    <P ID="edit" class=small>(Edited by sdckapr on 10-Mar-06 08:20. OOPs. I missed that the pics did not align with modeList.)</P>This is what I was alluding to.

    Steve
    PS I missed that your pictures did not align with your modeList. Try this instead

  10. #10
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    Thanks You very much for your help this a very cool thing

  11. #11
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    yes exactly right

    very good

  12. #12
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXC

    Well as my post seems to be totally sidelined, mine allows you to add pictures automatically without the use of code as the lookups are already in place <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Jerry

  13. #13
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXC

    Yes, yours is a great way without code.

    One of the downsides is that all the ranges with the pics must be a named formula. It all depends on what the requirements are.

    Steve

  14. #14
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXCEL 03)

    Two questions I have is

    1.
    If i want to add another picture how do i do this

    Option Explicit
    Private Sub CheckBox1_Click()
    With Me
    If .ComboBox1.Value = "Down Tubing" Then
    .Shapes("pic 2").Visible = Not .CheckBox1.Value
    .Shapes("pic 1").Visible = .CheckBox1.Value
    End If
    End With
    End Sub

    Private Sub ComboBox1_Change()

    Dim x As Integer
    With Me
    For x = 1 To 5
    .Shapes("pic " & x).Visible = False
    Next
    On Error Resume Next
    x = Application.WorksheetFunction. _
    Match(ComboBox1.Value, .Range("modelist"), 0)
    On Error GoTo 0

    Select Case x
    Case 2, 3
    .Shapes("pic " & x + 1).Visible = True
    Case 4
    .Shapes("pic 2").Visible = Not .CheckBox1.Value
    .Shapes("pic 1").Visible = .CheckBox1.Value
    Case 5
    .Shapes("pic 5").Visible = True

    End Select
    End With
    End Sub
    works but not sure if this is what i really should do

    2.
    where can i see all my pictures?

    thanks

  15. #15
    2 Star Lounger
    Join Date
    May 2005
    Location
    Wilcox, Saskatchewan
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HIDE AND SHOW PICTURES BASE ON CONDITIONS (EXC

    Jezza I am actually just learning how you did what you did, I m not to sure how to set up the pic list

    where do I put the formulas you show?

Page 1 of 2 12 LastLast

Posting Permissions

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