|
老师:帮我看一下这个代码
要求:
1、整理:有数据的单元格汇总到新的表中。(没有数据的单元格不需要汇总)
2、排序:相同类别的产品“类别名称"合并,并添加边框。
Private Sub CommandButton1_Click()
Dim i As Integer, j As Integer
Dim s As String
Dim rng As Range
Set rng = Range("a3").CurrentRegion
rng.Sort key1:=Range("a2"), order1:=xlAscending, Header:=xlNo
Application.DisplayAlerts = False
With ActiveSheet
j = .Range("a1").End(xlDown).Row
For i = j To 2 Step -1
If .Cells(i, 1).Value = .Cells(i - 1, 1).Value Then
.Range(.Cells(i - 1, 1), .Cells(i, 1)).Merge
End If
Next
End With
Application.DisplayAlerts = True
rng.Borders.LineStyle = 1
End Sub |
|