+ Reply to Thread
Results 1 to 6 of 6

Button to show/hide a picture in a sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    09-13-2008
    Location
    PA
    Posts
    3

    Button to show/hide a picture in a sheet

    Is it possible to add a button to show/hide a picture in a worksheet?

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    notchristopher,

    Welcome to the forum. Please read forum rules below before posting again.
    Your thread moved to programming

    Try something like. Change picture 1 to your picture name

    ActiveSheet.Shapes("Picture 1").Visible = False
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    09-13-2008
    Location
    PA
    Posts
    3
    my bad thanks

  4. #4
    Registered User
    Join Date
    09-13-2008
    Location
    PA
    Posts
    3
    can you fix this for me please? not a coder..

    Sub Button1_Click()
    If Visible("Units-1.JPG") = True Then
    ActiveSheet.Shapes("Units-1.JPG").Visible = False
    Else
    ActiveSheet.Shapes("Units-1.JPG").Visible = True
    End Sub

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485
    You need to test the visibility of the shape before changing it.
    So rather than your test of Visible() use the same references to the sheet and shape.

    Sub Button1_Click()
    
    If ActiveSheet.Shapes("Units-1.JPG").Visible = True Then
    ActiveSheet.Shapes("Units-1.JPG").Visible = False
    Else
    ActiveSheet.Shapes("Units-1.JPG").Visible = True
    
    
    End Sub
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Or

    ActiveSheet.Shapes("Units-1.JPG").Visible = _
    Not ActiveSheet.Shapes("Units-1.JPG").Visible
    or
    With ActiveSheet.Shapes("Units-1.JPG")
        .Visible = Not .Visible
    End With
    VBA Noob
    Last edited by VBA Noob; 09-14-2008 at 08:09 AM.

+ 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. send sheet as an email based on the sheet name.
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-07-2008, 02:24 AM
  2. populate sheet 2 using sheet 1 with a drop down
    By IslandBoy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2007, 11:51 AM
  3. Replies: 2
    Last Post: 10-10-2007, 09:14 PM
  4. Links in same spreadsheet problem
    By dyun1dyun1 in forum Excel General
    Replies: 4
    Last Post: 04-21-2007, 12:17 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