实际上,我是使用宏的新手,并且在绘制边界线以将所有数据分组为同一日期时遇到了一些困难。我的代码如下所示,如果有人能帮助我解决这个问题,不胜感激。结果应如附图所示。
==================================================== =======================================
Public i As Integer
Sub GetCellValue()
Dim rngEnd As Range
NumRows = Range("A3", Range("A3").End(xlDown)).Rows.Count
Range("A3").Select
For i = 3 To NumRows
If Cells(i, 1).Value <> Cells(i + 1, 1).Value Then
Call BorderCode
Cells(i + 1, 1).Select
End If
Next
End Sub
Sub BorderCode()
Range(Cells(3, 1), Cells(i, 11)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone