欄位5複選單會選到空白,有沒有辦法可以忽略空白
因為我常常會更新欄位5的選單
Private Sub ListBox1_Change()
If Reload Then Exit Sub
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then t = t & ";" & ListBox1.List(i) '分號「;」為間隔多個選項間的符號,可自行設定
Next
ActiveCell = Mid(t, 2)
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ListBox1
If ActiveCell.Column = 6 And ActiveCell.Row > 1 Then '儲存格「欄」為「2」,依照自己的需求修改
j = ActiveCell.Value
Reload = True
For i = 0 To .ListCount - 1
If InStr(j, .List(i)) Then
.Selected(i) = True
Else
.Selected(i) = False
End If
Next
Reload = False
.Top = ActiveCell.Top + ActiveCell.Height
.Left = ActiveCell.Left
.Width = ActiveCell.Width
.Visible = True
Else
.Visible = False
End If
End With
End Sub
For i = 0 To ListBox1.ListCount - 1
***這裡再加 if, 非空白才繼續, 是想達成這樣嗎?***
If ListBox1.Selected(i) = True Then t = t & ";" & ListBox1.List(i) '分號「;」為間隔多個選項間的符號,可自行設定
Next