2、打开你需要创建三选一按钮的表的设计视图。
3、设置你需要三选一的字段的数据类型:常规标签里的设置跟你以前的设置不变;查阅标签里,显示控件设置为“列表框”,行来源类型设置为“表/查询”;行来源设磨族置为“表2”;绑定列和列数都设置为“1”。
4、经过以上设置后,保存。
你再打开表输入数据时,你需要三选一的字段在录入时就可以选择录入了。
'主体函数Sub defen()
Dim a As String, b As String
For n = 1 To 3 '需芦贺要改下这里,这是行数
a = fenzu(Cells(n, 1))
paixu a
b = fenzu(Cells(n, 2))
paixu b
If a = b Then
Cells(n, 3) = 2
Else
If InStr(1, a, b) Then
Cells(n, 3) = 1
Else
Cells(n, 3) = 0
End If
End If
Next
End Sub
'防止答案或漏哗搜者标准答案顺序不对返历,按字母顺序排序
Sub paixu(shu As String)
Dim a, c
Dim i As Integer, temp
a = Split(shu, ",")
For i = 0 To UBound(a) - 1
If (a(i) >a(i + 1)) Then '若是递减,改为a(i)<a(i+1)
temp = a(i)
a(i) = a(i + 1)
a(i + 1) = temp
End If
Next
shu = Join(a, "")
End Sub
'为了排序,每个字母之间插入逗号
Function fenzu(t As Range) As String
Dim a As String, b As String
a = ""
b = UCase(t)
For m = 1 To Len(b)
a = a &Mid(b, m, 1) &","
Next
fenzu = Mid(a, 1, Len(a) - 1)
End Function
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)