求求大佬抽空帮邦忙,感谢
excel吧
全部回复
仅看楼主
level 4
石坚仔 楼主
大佬们,请帮忙看看
我想在表1每列的单元格输入表2(代码库)中对应内容的代码,在表1单元格中能自动引用表2(代码库)中此代码所对应的中文显示名。
请赐教,小弟在此深表感谢!
2022年05月10日 00点05分 1
level 6
这想法真是有点不理解,为什么要这么曲折地输入那些信息呢?如果不想打字,也不是很多内容啊,直接下拉菜单不行吗?
2022年05月10日 02点05分 3
嗯嗯,后面就是用了你这个方法,谢谢!
2022年05月11日 13点05分
吧务
level 15
可以用vba实现.
2022年05月10日 02点05分 4
谢谢
2022年05月11日 13点05分
level 11
'当前表一工作表change事件
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Rows.Count + Target.Columns.Count > 2 Then Exit Sub
 If Target.Row < 3 Then Exit Sub
 Dim d, t
 Call setdic(d)
 t = Cells(2, Target.Column).Value
 If Not d(0).exists(t) Then Exit Sub
 If d(d(0)(t)).exists(Target.Value) Then
  Application.EnableEvents = False
  Target.Value = d(d(0)(t))(Target.Value)
  Application.EnableEvents = True
 End If
End Sub
Function setdic(d)
 Dim a, i, j
 a = Sheets("表二(代码库)").[a1].CurrentRegion.Value ' 全角括号
 If UBound(a, 2) Mod 2 Then MsgBox "偶数行!": End
 ReDim d(UBound(a, 2) / 2)
 Set d(0) = CreateObject("scripting.dictionary")
 For j = 1 To UBound(a, 2) Step 2
  If Len(a(1, j + 1)) Then
   d(0)(a(1, j + 1)) = (j + 1) / 2
   Set d((j + 1) / 2) = CreateObject("scripting.dictionary")
   For i = 2 To UBound(a)
    If Len(a(i, j)) Then d((j + 1) / 2)(a(i, j)) = a(i, j + 1)
   Next
  End If
 Next
End Function
2022年05月10日 03点05分 6
这对我太难了,谢谢
2022年05月11日 13点05分
1