Border around each cell in a range

前端 未结 7 1880
你的背包
你的背包 2020-12-14 00:38

I am trying to create a simple function that will add borders around every cell in a certain range. Using the wonderful recording this generates a ton of code which is quite

7条回答
  •  粉色の甜心
    2020-12-14 00:58

    Here's another way

    Sub testborder()
    
        Dim rRng As Range
    
        Set rRng = Sheet1.Range("B2:D5")
    
        'Clear existing
        rRng.Borders.LineStyle = xlNone
    
        'Apply new borders
        rRng.BorderAround xlContinuous
        rRng.Borders(xlInsideHorizontal).LineStyle = xlContinuous
        rRng.Borders(xlInsideVertical).LineStyle = xlContinuous
    
    End Sub
    

提交回复
热议问题