|
楼主 |
发表于 2017-1-10 07:27
|
显示全部楼层
本帖最后由 lsc900707 于 2017-1-10 21:39 编辑
如何修改代码实现选择文字显示数字?
http://club.excelhome.net/thread-1323039-1-1.html
(出处: ExcelHome技术论坛)
设置不同的数据有效性并按要求显示:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Str
If Target.Row < 4 Or Target.Column > 13 Then
Exit Sub
Else
Str = Target.Value
Target.Value = Left(Str, 1)
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 8 Or Target.Column <> 12 Or Target.Column <> 13 Then
Target.Validation.Delete
End If
If Target.Row > 4 And Target.Column = 8 Then
Target.Validation.Add xlValidateList, , , "1.国有,2.集体,3.个体,4.其他,"
ElseIf Target.Row > 4 And Target.Column = 12 Then
Target.Validation.Add xlValidateList, , , "1.水田,2.草地,3.林地,"
ElseIf Target.Row > 4 And Target.Column = 13 Then
Target.Validation.Add xlValidateList, , , "1.左,2.右,3.前,4.后,5.上,6.下"
End If
End Sub
|
评分
-
1
查看全部评分
-
|