+ Reply to Thread
Results 1 to 6 of 6

Make shapes appear and hide according to value in cell

Hybrid View

  1. #1
    Registered User
    Join Date
    03-04-2020
    Location
    Paris, France
    MS-Off Ver
    356 Pro Plus
    Posts
    3

    Make shapes appear and hide according to value in cell

    I am using the following code to hide a shape when A1 = any other value than 1. This works when I manually change the value but it doesn't work when the cell value is calculated with a formula. Any ideas how I can get this or another approach to work?

    [Code]
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 1 And Target.Column = 1 Then _
    Me.Shapes("Rectangle 3").Visible = (Cells(1, 1).Value = 1)
    End Sub
    [Code]


    I am using the value in the cell A1 as a switch; 1= incomplete data, which is calculated on the same sheet according to data on a seperate sheet (same workbook).

    [Formulas]
    A1: =IF(L24 = "Please Complete Form", 2, 1)

    L24: =IF(COUNTIF('Workplace Questionnaire'!$U$10:$U$101,"*"&Options!$C$7&"*")>0, "Please Complete Form", (COUNTIF('Workplace Questionnaire'!$U$10:$U$101, C24)))
    [Formulas]

    I am using the shape to hide graphic printouts relating to the data gathered on the data sheet. The idea is that the graphs are shown only when all data is fully entered.

    NB. I've shared the formulas to add context, and to demonstrate that I am using them with the macro - don't worry too much if they are inaccurate, I've been playing around with them to see if i can jigg it all in to place.

    Thanks in advance!

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: Make shapes appear and hide according to value in cell

    You'd need the Worksheet_Calculate event:

    Private Sub Worksheet_Calculate()
    Me.Shapes("Rectangle 3").Visible = (Cells(1, 1).Value = 1)
    End Sub
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    03-04-2020
    Location
    Paris, France
    MS-Off Ver
    356 Pro Plus
    Posts
    3

    Re: Make shapes appear and hide according to value in cell

    Thank you. Is that code added below, above to instead of the code I am using? I am new to VBA, if that wasn't obvious.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: Make shapes appear and hide according to value in cell

    That would replace what you currently have.

  5. #5
    Registered User
    Join Date
    03-04-2020
    Location
    Paris, France
    MS-Off Ver
    356 Pro Plus
    Posts
    3

    Re: Make shapes appear and hide according to value in cell

    so, its added below the existing code?

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: Make shapes appear and hide according to value in cell

    No, it would replace what you have now. Since that won't work with a formula, there is no point in keeping it.

+ 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. Making VBA Macro to make shapes disappear if cell has certain value (Multiple Shapes)
    By Nicholaes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2019, 06:33 PM
  2. [SOLVED] How to hide shapes based on numerous cell values
    By willastrowalker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2017, 02:50 AM
  3. Hide / Unhide Shapes Based on Cell Selection
    By ckoolsurf in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2015, 05:33 PM
  4. [SOLVED] Unhide & hide Shapes.
    By pipoliveira in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-14-2013, 07:41 AM
  5. VBA to Show/Hide multiple shapes based on cell values
    By Mike_Taylor16 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-22-2013, 03:29 PM
  6. Can I Hide Shapes That Are Buttons???
    By JonesZoid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2012, 05:32 PM
  7. Hide shape based on cell value - For mutliple shapes
    By [Jimmy] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2012, 09:36 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