How do I draw borders around a cell or range in an excel sheet?
‘Code by Mahipal Padigela ‘Open Microsoft Excel ‘Goto VBA Editor (Press Control+F11 or navigate Menu Tools–>Macro–>Visual BAsic Editor) ‘Insert a Module (Right click your file name in the VB editor–>Insert–>Module) ‘Paste the following code into the Module1 Sub DrawBorders() Dim strRng1 As String Dim strRng2 As String strRng1 = “A5:D10” ‘set some test range strRng2 = “C16:G20” ‘set some test range ‘If you need to draw all the borders with same properties, use this ActiveSheet.Range(strRng1).BorderAround xlContinuous, xlMedium, 46 ‘Or if you need to draw the borders individually, applying different properties to each, use this ActiveSheet.Range(strRng2).Borders(xlEdgeLeft).LineStyle = xlContinuous ActiveSheet.Range(strRng2).Borders(xlEdgeLeft).ColorIndex = 4 ActiveSheet.Range(strRng2).Borders(xlEdgeTop).LineStyle = xlContinuous ActiveSheet.Range(strRng2).Borders(xlEdgeTop).ColorIndex = 3 ActiveSheet.Range(strRng2).Borders(xlEdgeBottom).LineStyle = xlContinuous ActiveSheet.Range(strR