>>348
そんなことするなら素直に
>セルごとに隣接判定をして罫線を描く/描かないの処理
を実装すればいいんじゃねえかと
Sub test()
Dim r As Range
Dim r2 As Range
Set r2 = Selection
For Each r In Selection
If Not isSelect(r, xlEdgeTop) Then r.Borders(xlEdgeTop).LineStyle = xlContinuous
If Not isSelect(r, xlEdgeBottom) Then r.Borders(xlEdgeBottom).LineStyle = xlContinuous
If Not isSelect(r, xlEdgeLeft) Then r.Borders(xlEdgeLeft).LineStyle = xlContinuous
If Not isSelect(r, xlEdgeRight) Then r.Borders(xlEdgeRight).LineStyle = xlContinuous
Next
End Sub
Function isSelect(testRange As Range, index As XlBordersIndex) As Boolean
On Error Resume Next
Dim r As Range
For Each r In Selection
Select Case index
Case xlEdgeTop
If r.Address = testRange.Offset(-1, 0).Address Then isSelect = True
Case xlEdgeBottom
If r.Address = testRange.Offset(1, 0).Address Then isSelect = True
Case xlEdgeLeft
If r.Address = testRange.Offset(0, -1).Address Then isSelect = True
Case xlEdgeRight
If r.Address = testRange.Offset(0, 1).Address Then isSelect = True
End Select
Next
End Function
こんな感じか。行数制限あるからやってるけど、1行If は推奨しないぞ