|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Target.Count > 1 Then Exit Sub
- If Target.Column <> 1 Or Target.Row < 2 Then Exit Sub
- Dim k, t, Arr, i&, j&, aa, oCtrl
- Set d = CreateObject("Scripting.Dictionary")
- On Error Resume Next
- Arr = [d1].CurrentRegion
- For i = 1 To UBound(Arr, 2)
- d(Arr(1, i)) = i
- Next
- k = d.keys
- t = d.items
- With Application.CommandBars.Add("临时菜单", msoBarPopup, , 1)
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "请选择"
- .FaceId = 136
- End With
- For i = 0 To UBound(k)
- With .Controls.Add(msoControlPopup, 1, , , 1)
- .BeginGroup = True
- .Caption = k(i)
- For j = 2 To UBound(Arr)
- If Arr(j, t(i)) <> "" Then
- Set oCtrl = .Controls.Add(Type:=msoControlButton)
- With oCtrl
- .Caption = Arr(j, t(i))
- .HelpFile = k(i) '引用Helpfile属性得到上一级菜单的Caption
- .OnAction = "yy1"
- End With
- End If
- Next
- End With
- Next
- .ShowPopup '显示工具栏
- End With
- Application.CommandBars("临时菜单").Delete '删除工具栏
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|