乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > Excel中如何根据下拉框选择的内容指定宏? 如单元格a1做...-excel下拉菜单宏,取消excel下拉菜单

Excel中如何根据下拉框选择的内容指定宏? 如单元格a1做...-excel下拉菜单宏,取消excel下拉菜单

作者:乔山办公网日期:

返回目录:excel表格制作


那么,你需要学习窗体,并在窗体中使用各类控件。

做个启动的代码zd,在sheet里面用change触发

Private Sub Worksheet_Change(ByVal Target As Range)
if target.address=$A$1 then
    if cells(1,1)=1  then
        call 1
    elseif cells(1,1)=2  then
        call 1
    ……
    endif
else
    exit sub
endif
End Sub

大概是这样


在工具栏上copy右击,单击自定义项目,在命令选项止中找到类别中的“宏”,在右侧,把 自定义宏按钮拖拽到工具栏上合适的位置,右击这个按钮,指定宏,改名称,改按钮上的图案,这都是可以的。

最后再关闭对话框就可以了。,纯手打,望采纳答案哦,谢谢

在SHEET1和SHEET2的A1单元格分别设置下拉菜单"A,B"
然后在两个工作e68a84e8a2ade79fa5e98193362表中分别加入如下代码:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRow, iCol As Integer
iRow = Target.Row
iCol = Target.Column
If iRow = 1 And iCol = 1 And Target <> "" Then
Application.EnableEvents = False
Application.ScreenUpdating = False
On Error Resume Next
If [A1] = "B" Then
Sheets("Sheet2").Visible = True
Sheets("Sheet1").Visible = False
Sheets("Sheet2").Select
Else
If [A1] = "A" Then
Sheets("Sheet1").Visible = True
Sheets("Sheet2").Visible = False
Sheets("Sheet1").Select
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End If
End Sub

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网