シートで値が連続する場合に、その区切りで罫線を引くためのマクロ
ExcelVBA
Option Explicit
Sub Drawlines()
Dim i As Integer
Dim mc As Integer '連続性を判定する列
Dim bm As Variant '一つ上のセル内容
Dim am As Variant 'セル内容
mc = InputBox("連続データが入力されている列を教えてください", "連続データの列")
bm = 0
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row + 1
am = Cells(i, mc)
If bm <> am Then
Range(Cells(i, mc).Address(False, False)).EntireRow.Select
Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
bm = am
End If
Next i
Cells(1, mc).Select
End Sub