我有一個列表 - 這是我剛剛發現這個語法,將允許多選擇從我的名單:檢查數組在VBA
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Address = "$B$1" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
Target.Value = Oldvalue & ", " & Newvalue
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
我可以告訴大家,選擇值的列表將被存儲在可變Target.Value
- 但我怎麼:
1)檢查
Target.Value
(這樣的長度,我知道如果我選擇1或多層)2)遍歷每個選擇?
您的GoTo Exitsub都可以用'Exit'替換。 – Andreas
你的意思是你想要一個數字值的字符串的長度? 'Len(target.value)' – Andreas
@Andreas - 讓我們說列表值是紅色,綠色,藍色 - 我需要一種方法來知道選擇了什麼東西像foeach(在Target.Value中選擇字符串)msgBox.Show(pick)下一個 –