|
▼Jto さん:
もし上の理解が正しければ、アップされたコードの
Initializeルーティンも、SpinButton1_Changeルーティンも不要かと。
ユーザーフォームモジュールを以下だけにするとどうでしょうか。
Private Sub CommandButton1_Click()
Call ListSet(1)
End Sub
Private Sub CommandButton2_Click()
Call ListSet(2)
End Sub
Private Sub CommandButton3_Click()
Call ListSet(3)
End Sub
Private Sub CommandButton4_Click()
Call ListSet(4)
End Sub
Private Sub CommandButton5_Click()
Call ListSet(5)
End Sub
Private Sub CommandButton6_Click()
Call ListSet(6)
End Sub
Private Sub CommandButton7_Click()
Call ListSet(7)
End Sub
Private Sub CommandButton8_Click()
Call ListSet(8)
End Sub
Private Sub CommandButton9_Click()
Call ListSet(9)
End Sub
Private Sub CommandButton10_Click()
Call ListSet(10)
End Sub
Private Sub ListSet(idx As Long)
Dim ch As String
Dim pos As Long
Dim cnt As Long
Dim myR As Range
ch = Array("あ", "か", "さ", "た", "な", "は", "ま", "や", "ら", "わ")(idx - 1)
Set myR = Range("A2", Range("A" & Rows.Count).End(xlUp))
cnt = WorksheetFunction.CountIf(myR, ch)
If cnt = 0 Then
MsgBox "[" & ch & "]から始まる名前は登録されていません"
Else
pos = WorksheetFunction.Match(ch, myR, 0) + 1
ListBox1.Clear
ListBox1.List = Cells(pos, 1).Resize(cnt, 2).Value
End If
Set myR = Nothing
End Sub
|
|