+ Reply to Thread
Results 1 to 3 of 3

How to make a shape display when a cell is click.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-21-2009
    Location
    Minnesota
    MS-Off Ver
    Excel 2003
    Posts
    5

    How to make a shape display when a cell is click.

    Need help with programming.
    This is what I am trying to do:

    When a user click on a cell in column A, a shape appears. And when they click on a cell other than a cell in column A, a shape disappears. The cell in Column A has no value.

    Here is my code so far:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Excel.Range
    Set r = Me.Range("A140:A150")
    
    With ActiveSheet.Shapes("Create_New_Row")
    If Target.Value = "new" Then
    .Visible = True
    Else
    .Visible = False
    End If
    End With
    End Sub
    Please help...

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How to make a shape display when a cell is click.

    It sounds like you need to use the Worksheet_SelectionChange event instead to get your code to respond to a click.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    '
    End Sub

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to make a shape display when a cell is click.

    I think this will do what you want. This goes in the sheet's code module.
    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
        ActiveSheet.Shapes("Create New Row").Visible = (Target.Column * Target.Cells.Count = 1)
    End Sub
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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