--------------------------------------------------------------------------------
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
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 Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
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
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
- Copy the macro using CTRL+C keys.
- Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
- Left Click on View Code in the pop up menu.
- Paste the macro code using CTRL+V
- Make any custom changes to the macro if needed at this time.
- 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 Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks