+ Reply to Thread
Results 1 to 4 of 4

Thread: moving mouse over a cell to show hid a shape

  1. #1
    Registered User
    Join Date
    05-15-2011
    Location
    iraq
    MS-Off Ver
    Excel 2003
    Posts
    2

    moving mouse over a cell to show hid a shape

    --------------------------------------------------------------------------------

    hi
    i am new here,

    i want to creat a VB code in excel for show hid a shape like rectanguler or trangle that contain comment... by moving mouse over a cell. i searched sites but didnt get codes like this..
    thank u very much

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: moving mouse over a cell to show hid a shape

    Hello aryanarch,

    Welcome to the Forum!

    I think the easiest solution is to use a regular comment. You can then change the comment's size, color, text, etc using VBA. When the mouse moves over the cell with the shape will be displayed.

    Add a comment to cell "A1". Add the macro below to the same sheet and run it. The macro will change into a right triangle.

    Sub CommentTest()
    
      Dim Cmt As Comment
      
        Set Cmt = Range("A1").Comment
        
          With Cmt
            .Shape.AutoShapeType = msoShapeRightTriangle
            .Shape.TextFrame.AutoSize = True
          End With
      
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-15-2011
    Location
    iraq
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: moving mouse over a cell to show hid a shape

    thanx Leith Ross
    but i want to create a rectangular shape on other side of sheet and writ comments in it. when the mouse over cell A1 it show me comment in the rectangular. and when the mouse over cell A2 it show me comment in the same rectangular

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: moving mouse over a cell to show hid a shape

    Hello ,

    Add this macro to the worksheet the rectangle shape is on. The macro allows only cells in column "A" to be displayed. You can change this if you need to. Change the name of the rectangle (Rectangle 1) to the name of your shape. Here is the macro code.
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
      If Not Intersect(Target, Range("A:A")) Is Nothing Then
        ActiveSheet.Shapes("Rectangle 1").TextFrame.Characters.Text = Target.Text
      End If
      
    End Sub

    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Make any custom changes to the macro if needed at this time.
    6. Save the macro in your Workbook using CTRL+S
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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.2.0