Point:選択した範囲に対して斜めに罫線を引きたい。(選択するセルは、縦横同じ数にしないと怒られます。)
Sub Test()
Tate = Selection.Rows.Count
Yoko = Selection.Columns.Count
Hidariue = Selection.Row
Hidarisita = Selection.Row + Tate - 1
Migiue = Selection.Column
If Tate <> Yoko Then
MsgBox "セルの縦横の個数が合いません!!", vbCritical
Exit Sub
End If
res = MsgBox("/←はい or \←いいえ", vbQuestion +
vbYesNo)
If res = 7 Then
For i = Hidariue To Hidarisita
p = Migiue
With Cells(i,
p).Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Migiue = Migiue + 1
Next i
Else
For a = Hidarisita To Hidariue Step -1
b = Migiue
With Cells(a,
b).Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Migiue = Migiue + 1
Next a
End If
End Sub |