logo
search
VBA & Macro Problems

How to Hide or Show an Excel Shape Based on Cell Value Using VBA

Ayan MasoodAyan Masood Oct 20, 2026 868 views

Question details

The user needs to use Excel VBA to dynamically hide or display a specific shape (named "Next Stage") based on whether a target cell (I33) contains the text "Pass".

How to Hide or Show an Excel Shape Based on Cell Value Using VBA
Product
Excel
Device & OS
not provided
Scenario
Automating spreadsheet interactivity where graphical elements, such as instructional arrows or stage indicators, respond to user inputs or specific cell values.
Observed behavior
The shape needs to automatically become visible when cell I33 equals "Pass" and hide itself when the cell contains any other value, without requiring the user to manually run a macro.
Before you start

Ensure you have the Developer tab enabled in your Excel ribbon and that macros are enabled in your Trust Center settings, otherwise the VBA event will not trigger.

Solution 1Recommended

Use Worksheet_Change Event in VBA

Implement a VBA script within the specific worksheet module to automatically monitor cell changes and update the shape's visibility properties.

To make a shape react to cell inputs in real-time, you must use the Worksheet_Change event. This special event runs automatically whenever a cell's value is modified by the user or by an external link.

It is highly recommended to change the shape's properties directly rather than selecting the shape first, as selecting objects can slow down your macro and cause screen flickering.

1
Open the VBA Editor

Navigate to the Developer tab on the Excel ribbon and click 'Visual Basic', or simply press Alt + F11 on your keyboard to open the VBA Editor window.

2
Select the Appropriate Worksheet Module

In the Project Explorer pane on the left, find your workbook and double-click the specific worksheet name (e.g., Sheet1) where your target cell and shape reside. Do not put this code in a standard module (like Module1), as Worksheet_Change events only trigger from worksheet modules.

3
Insert the Event Code

Paste the required VBA code into the code window. Use an IF statement to check if 'Target.Address' equals '"$I$33"'. If it does, set the visibility of 'Me.Shapes("Next Stage")' based on whether 'Target.Value' equals '"Pass"'.

4
Test the Automation

Close the VBA Editor and return to your worksheet. Type 'Pass' into cell I33 and press Enter. The shape named 'Next Stage' should immediately appear. Change the text to something else, and the shape will hide.

Use Worksheet_Change Event in VBA
Correct Shape Naming: Ensure the shape is actually named 'Next Stage'. You can verify or change a shape's name by clicking on the shape and looking at the Name Box located to the left of the formula bar.
Powerful VBA Support

Automate Spreadsheets with WPS Office

WPS Spreadsheet provides comprehensive support for VBA macros. You can easily automate tasks, such as hiding shapes based on cell values, using the exact same code you would use in Microsoft Excel.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open your macro-enabled spreadsheet.
  2. 2. Access the Developer Tab: Navigate to the Developer tab on the top ribbon and click on 'VBA Editor'.
  3. 3. Add the Worksheet_Change Macro: Double-click your active sheet in the Project Explorer and paste your shape visibility VBA code to enable real-time automation.
Fully compatible with Microsoft Excel VBA scripts and macro formats (.xlsm)Free, lightweight, and fast spreadsheet editorEasily access Developer tools and manage form controls
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my Worksheet_Change macro triggering?

This usually happens for two reasons: either macros are disabled in your Trust Center settings, or the VBA code was accidentally placed in a standard module (e.g., Module1) instead of the specific worksheet module where the cell change occurs.

How do I find or change the exact name of a shape in Excel?

Click on the shape in your worksheet. Look at the Name Box, which is located directly to the left of the formula bar. You can type a new name, such as 'Next Stage', in this box and press Enter to rename it.

Do I need to select the shape in VBA to change its visibility?

No, it is a best practice to modify the shape's properties directly (e.g., using `Me.Shapes("ShapeName").Visible = msoTrue`) rather than selecting it first. Bypassing the selection step makes your macro run faster and cleaner.

Can I use this method to monitor multiple cells?

Yes. You can modify the VBA code using the `Intersect` method or logical operators within your Worksheet_Change event to check if the changed target falls within a specified range of multiple cells.