|
已知物料代号快速输入物料名称
输入物料代号后,按鼠标右键,点击快捷键,在右边的单元格中直接输入物料名称
1.做好物料名称对照表
2.设置鼠标右键“物料名称”,连接代码
Private Sub Workbook_Open()
Set Amenu = Application.CommandBars("cell").Controls.Add(Type:=msoControlButton)
Amenu.Caption = "物料名称"
Amenu.OnAction = "Macro1"
End Sub
3.代码放在模块中
Application.ScreenUpdating = False
X = ActiveCell.Row
Y = ActiveCell.Column
A = Selection.Rows.Count
For B = 0 To A - 1
Cells(X + B, Y + 1).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'[mm.xls]mm'!C1:C2,2,0)"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Next
4.退出时,消除快捷键
5.将文件储存在Xlstart文件夹中,设为隐藏文件
这样在任何文件中使用 |
|