Sub Main()
Dim Rng As Range
Set Rng = Selection
If Rng.Count > 1 Then
MsgBox "只能选择一个单元格!"
Exit Sub
End If
Call LuoJi(Rng, 0)
End Sub
Function LuoJi(Rng As Range, Lei As Integer)
Dim NO1 As Boolean
If Lei <> Rng.Column Then
NO1 = True
End If
Lei = Rng.Column
If Rng.Offset(1, 0) <> "" Then
If NO1 Then
Else
Call Hx(Rng, True, 0)
End If
Set Rng = Rng.Offset(1, 0)
Else
If NO1 Then
Call Hx(Rng, 0, 1)
NO1 = False
Else
Call Hx(Rng, 1, 1)
End If
Set Rng = Rng.Offset(0, 1)
End If
Debug.Print Rng.Row & "," & Rng.Column
If Rng.Column >= 15 Then
MsgBox "完成!"
Exit Function
End If
Call LuoJi(Rng, Lei)
End Function
Function Hx(Rng As Range, Zb As Boolean, Xb As Boolean)
If Zb Then
With Rng.Borders(xlEdgeLeft)
.Weight = xlThick
.LineStyle = xlContinuous
.Color = 255
End With
End If
If Xb Then
With Rng.Borders(xlEdgeBottom)
.Weight = xlThick
.LineStyle = xlContinuous
.Color = 255
End With
End If
End Function