すいません、質問です。

1004エラーが出ます。(´Д`;
worksheet記述を加えてみたり、色々試してみたのですが消えません。

作りたいものとしては、
A列を縦にチェックして異なる文字列が出てきたら罫線(太線)を引く、
というものです。
突っ込み、お願いします。

Sub test()
  Dim i As Integer
  Dim st_flag As Byte
  Dim range1 As Range
  
  st_flag = 0
  i = 3
  Do While Cells(i, 1).Value <> ""
    If (st_flag = 1) Then
      If (Cells(i, 1).Value <> Cells(i - 1, 1).Value) Then
        Range(Cells(i, 1), Cells(i, 6)).Borders(xlEdgeTop).LineStyle = xlMedium
      End If
    Else
      st_flag = 1   ''最初の1セルは比較をしない
    End If
    i = i + 1
  Loop
End Sub