'カーソルかざすと表示-----------------------------

Private Sub CommandButton8_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
TextBox1.Value = "残存量の一覧が閲覧を閉じる時は必ずこのボタンで終了してください。"

End Sub
'---------------------------------------------------------

Sub 適用法令を検索してTextに表示()

Dim R1 As Range
Dim R2 As Range
Dim Prev As Integer
Dim S As String
Dim H As String '検索値
Dim R As Range '検索範囲
Dim E As Integer '照合型
Dim ans As String


    With Worksheets("data")
        Set R1 = .Columns(4).Find(what:=TextBox1.Text, lookat:=xlWhole)
            If R1 Is Nothing Then
                MsgBox TextBox1.Text & "データはありません。", vbInformation, "該当無し"
                Exit Sub
            End If
   
        Set R2 = .Rows(R1.Row).Find(what:="○", lookat:=xlWhole)
            If R2 Is Nothing Then
                MsgBox TextBox1.Text & "適用法令はありません。", vbInformation, "該当無し"
                Exit Sub
            End If
              
        Do While R2.Column > Prev
            S = S & IIf(S = "", "", ",") & .Cells(2, R2.Column).Value
            Prev = R2.Column
                Set R2 = .Rows(R1.Row).FindNext(R2)
        Loop
    End With
   
    TextBox4.Text = S
    TextBox1.SetFocus
   
    Worksheets("shukei").Activate
      H = TextBox1.Value  
    Set R = Range("A:A")
      E = 0 
    ans = Application.WorksheetFunction.Match(H, R, E)
   
    Cells(ans, 6) = S
   
End Sub

Sub 連番を入力する()

  Dim c As Range
  Dim i As Long

  i = 1

  For Each c In Selection
    c.Value = i
    i = i + 1
  Next

End Sub

'---------------------------------------------------------

Sub test()
 Dim i, 指定行, 連番
'指定行の指定
 指定行 = 1
 '連番開始番号の入力
 連番 = 1

 For i = 指定行 To Cells(Rows.Count, 1).End(xlUp).Row
 Cells(i, 1).Value = 連番
 連番 = 連番 + 1
 Next
 End Sub

'-----------------------------------------------------------------------------

Sub macro() 'B列の横にA列に連番
 Range("A3").Value = 1
 Range("A3").DataSeries xlColumns, xlDataSeriesLinear, , 1, Range("B" & Rows.Count).End(xlUp).Row - 2
 End Sub