我将字符串;#WR_1;#WR_2; #WR_3;#WR_4;#与VBA代码分开
Sub Splitfn()
Dim str As String
Dim var As Variant
Dim i As Long
str = ";#WR_1;#WR_2;#WR_3;#WR_4;#"
var = Split(str, ";#")
For i = 0 To UBound(var)
Debug.Print i, var(i)
Next i
End Sub
That returns
0
1 WR_1
2 WR_2
3 WR_3
4 WR_4
5
我想将这些值(WR_1,WR_2,WR_3,WR_4)添加到下拉列表中。如何在VBA代码中指定
答案 0 :(得分:1)
组合框接受字符串作为值列表:
sStr = ";#WR_1;#WR_2;#WR_3;#WR_4;#"
'' Var = Split(Str, ";#")
sStr = Replace(sStr, "#", "")
Me.Combo9.RowSourceType = "value list"
Me.Combo9.RowSource = sStr
第一个值为空,因为第一个字符是分隔符;
,如果不需要,则很容易更改:
sStr=Mid(sStr,2)
Me.Combo9.RowSource = sStr