Macro To Add Transparent Rectangle On Active Cell

The following code will generate a Transparent Rectangle with Red Border on the Active Cell, when executed.

Put the below code on the Personal Macro Workbook to have it available on all Excel Workbooks on your computer.

__________________________________________________________

Sub AddRectangle() 'Macro By Deep Dave on 21st Nov 2014 (www.NeedForExcel.com) 'Macro creates a Rectangle with a Red Border Application.ScreenUpdating = False 'Turns off screen updating Dim W As Worksheet Dim S As Shape Set W = ActiveSheet Set S = W.Shapes.AddShape(1, ActiveCell.Left, ActiveCell.Top, 60, 20) With S.Fill .Transparency = 1 '0 (Not Transparent) to 1 (Completely Transparent) End With S.Line.ForeColor.RGB = RGB(255, 0, 0) 'Red color applied to border Application.ScreenUpdating = True 'Turns on screen updating End Sub

__________________________________________________________

After putting the Macro on your Personal Macro Workbook, close the Visual Basic Window, and while on Excel, use the short keys Alt + F8 to open the Macro window that displays all available Macros.

Single Click on the Macro named AddRectangle, go to Options & assign Ctrl + Shift + R as the Short key to execute the Macro.

Everytime the combination of Ctrl + Shift + R is pressed, a Red Rectangle will be generated on the Active Cell.

#vba #macrotoaddrectangle #vbashapes #macros #exceltutorials #excelprogramming #excellessons #developertab #excel2007 #excel2010 #excel2013 #msexcel #office #microsoftexcel #exceltips #exceltricks

Follow Us
  • Twitter Basic Square
  • Google+ Basic Square
Recent Posts