Private Sub ListBox1_Click()
LL = ListBox1.ListIndex + 1
If LL > 0 Then
L0 = Int((LL - 1) / 4) + 1
r = 23 * L0 - 22
L1 = LL - ((L0 - 1) * 4)
'↑Case要有前因! L1 這個前因可能有多個
Select Case L1
'↑在 Select Case 與 End Select之間列出前因後果的種類
Case 1: c = 1
'↑當L1是 1 時 以:符號區隔!開始陳述結果(令c=1)
Case 2: c = 6
Case 3: c = 11
Case 4: c = 16
End Select
Unload Me
Cells(r, c).Select
End If
End Sub作者: lee88 時間: 2022-10-18 13:24
Private Sub ListBox1_Click()
LL = ListBox1.ListIndex + 1
if listbox1.list(1,0)="" then exit sub
...
...
...
...
也可以最後多加個判斷 讓他忽略
if r=1,c=6 then msgbox "此項為空" : Exit sub
Unload Me
cells(r,c).select
End sub