Tuesday, 10 September 2013

Macro: Drawing border line to group data within the same date

Macro: Drawing border line to group data within the same date

Actually I'm new for using macro, and I faced some difficulty for drawing
the border line to group all the data with same date. My code is shown
below here, appreciate if anyone able to help me up for this. And the
result should be displayed as attached pictured.
========================================================================================
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
'rngstart = Range(Cells(i, 1), Cells(i, 1))
'rngEnd = Range(Cells(i, 11), Cells(i, 11))
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
End Sub

No comments:

Post a Comment