|
Dim x1
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next '忽略错误提醒
If Target.Row < 3 Then Exit Sub
If Target.CountLarge <> 1 Then Exit Sub
If Target.Column > 6 Then Exit Sub
If Target.Count > 1 Then Exit Sub
x2 = 2
For i = 1 To 6
x2 = WorksheetFunction.Max(x2, Cells(Rows.Count, i).End(xlUp).Row)
Next
If x1 = x2 Then Exit Sub
If x1 < x2 Then x1 = x1 + 1: flag = True
If x2 < x1 Then x2 = x2 + 1: flag = False
With Range(Cells(x1, "A"), Cells(x2, "W"))
.Borders.LineStyle = flag
.HorizontalAlignment = xlCenter '添加表格线
.VerticalAlignment = xlCenter '添加表格线
.Font.Bold = True
If flag = True Then .Borders.LineStyle = xlDash
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
x1 = 2
For i = 1 To 6
x1 = WorksheetFunction.Max(x1, Cells(Rows.Count, i).End(xlUp).Row)
Next
End Sub
|
评分
-
1
查看全部评分
-
|