lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I came cross this website/code which I found it a bit difficult to understand. The author said he got help from this forum to learn vba; so I figured, then it must be better/easier coding than this to do the same from someone from here. i would appreciate any help. Thanks a lot.
[/FONT]https://www.thespreadsheetguru.com/blog/how-to-keep-track-of-your-shapes-created-with-vba-code[FONT="]
[/FONT]
I came cross this website/code which I found it a bit difficult to understand. The author said he got help from this forum to learn vba; so I figured, then it must be better/easier coding than this to do the same from someone from here. i would appreciate any help. Thanks a lot.
Rich (BB code):
[FONT="]Sub[/FONT][FONT="] RedBox()[/FONT]
[FONT="]'PURPOSE: Create a Red Box to Highlight Cell Selection[/FONT]
[FONT="]'SOURCE: www.TheSpreadsheetGuru.com[/FONT]
[FONT="]Dim[/FONT][FONT="] Box [/FONT][FONT="]As[/FONT][FONT="] Shape[/FONT]
[FONT="]'Create a Red Box based on Cell Selection[/FONT]
[FONT="] [/FONT][FONT="]On[/FONT][FONT="] [/FONT][FONT="]Error[/FONT][FONT="] [/FONT][FONT="]GoTo[/FONT][FONT="] Select_Cell:[/FONT]
[FONT="] [/FONT][FONT="]Set[/FONT][FONT="] Box = ActiveSheet.Shapes.AddShape( _[/FONT]
[FONT="] Type:=msoShapeRectangle, _[/FONT]
[FONT="] Left:=Selection.Left, _[/FONT]
[FONT="] Top:=Selection.Top, _[/FONT]
[FONT="] Width:=Selection.Width, _[/FONT]
[FONT="] Height:=Selection.Height)[/FONT]
[FONT="] [/FONT][FONT="]On[/FONT][FONT="] [/FONT][FONT="]Error[/FONT][FONT="] [/FONT][FONT="]GoTo[/FONT][FONT="] 0[/FONT]
[FONT="]'Rename Box with Tag[/FONT]
[FONT="] Box.Name = Box.Name & "_RedBox"[/FONT]
[FONT="]'Format the Red Box[/FONT]
[FONT="] Box.Fill.Visible = msoFalse[/FONT]
[FONT="] Box.Line.Visible = msoTrue[/FONT]
[FONT="] Box.Line.ForeColor.RGB = RGB(255, 0, 0)[/FONT]
[FONT="] Box.Line.Weight = 2.25[/FONT]
[FONT="]Exit[/FONT][FONT="] [/FONT][FONT="]Sub[/FONT]
[FONT="]'ERROR HANDLER[/FONT]
[FONT="]Select_Cell:[/FONT]
[FONT="] MsgBox "Select a cell in order to use this button."[/FONT]
[FONT="] [/FONT]
[FONT="]End[/FONT][FONT="] [/FONT][FONT="]Sub
[/FONT]https://www.thespreadsheetguru.com/blog/how-to-keep-track-of-your-shapes-created-with-vba-code[FONT="]
[/FONT]