我创建了一个通用的 excel 文件来帮助演示我想要做什么。我命名为 Tool.xlsm 的文件包含两个工作表;工作表 1 和工作表 2。Sheet1 将被设计为有几个可以接受用户输入的字段。Sheet2将从用户隐藏,但将包含各种下拉列表选择选项及其相应的描述,这些描述应在选择特定代码时在Sheep1上的另一个单元格中显示。此外,Sheet2 将在一列中包含许多 ID#,在下一列中包含它们对应的用户名。这样做的目的是让用户能够快速将 ID# 与其所属的用户相关联。
这是我到目前为止所拥有的......我怀疑我是否会尽可能高效地完成它,但我非常感谢你们的专业知识!
Sub Button1_Click()
'Based on selected value of C1, show corresponding message in J1'
'Can this be done by simply referencing the code descriptions in sheet2?'
If Range("C1") = "code 1" Then
Range("J1") = "code 1 description"
End If
If Range("C1") = "code 2" Then
Range("J1") = "code 2 description"
End If
'End of code selection'
End Sub
Sub Button2_Click()
'Based on ID# entered into C3, display corresponding name in J1 (Sheet2 contains ID#s with corresponding names)'
'There has to be an esier way to loop through 1000s of records and display corresponding ID# and Person''s name'
'Rather than assigning Person 1, to Range J1, I should be able to just reference the cell Sheet2!E3 but that doesn''t seem to work'
If Range("C3") = "1001" Then
Range("J1") = "Person 1"
End If
If Range("C3") = "34349090" Then
Range("J1") = "Person 83"
End If
'End ID# search'
End Sub
Sub Button3_Click()
'Clear unlocked cells'
End Sub