下拉菜单链接 [英] dropdown menu linking
问题描述
嘿,
想为我糟糕的英语道歉,但会尽量明白你的b $ b我刚从vba开始并有一个问题,但没有设法将下拉菜单链接到标签
已经制作了一个下拉菜单(在我称之为日历的选项卡上)一年中的几个月我现在想要参加vba
如果我点击1月份的选项,如果我点击2月到2月等,那么获取等等... ...
我怎么能这么简单地做到这一点?
谢谢你verry mutch
保罗
1)复制此代码。
2)对 - 单击工作表"日历"的工作表标签
3)选择"查看代码"
4)将代码粘贴到出现的窗口中。
5)将文件保存为启用宏的.xlsm文件。
6)根据需要对单元格地址进行更改 - 如下所示,下拉列表需要为DV列表在单元格C4上,并且在选择月度表时将选择单元格A1。
私有子工作表_更改(按范围目标作为范围)
&NBSP;如果Target.Address<> "
C
4英寸然后退出Sub¥
&NBSP;如果Target.Value =""然后退出Sub $
&NBSP; '关闭事件以避免循环
&NBSP; Application.EnableEvents = False
&NBSP;使用工作表(Target.Value)
&NBSP; &NBSP; &NBSP; .Activate
&NBSP; &NBSP; &NBSP; .Range(" A1")。选择
&NBSP;结束与$
&NBSP; Application.EnableEvents = True
End Sub
&NBSP;&NBSP;
Hey,
wants to apologize for my bad English but will try to be clear
I just started with vba and had a question but do not manage to link a dropdown menu to a tab
have made a dropdown menu (on the tab that I have called a calendar) with all months of the year in now I would like to be in vba
Obtain if I click the January choice that it goes to the January tab if I click February to February etc. etc ...
how can I do this in an easy way?
thank you verry mutch
Paul
1) Copy this code.
2) Right-Click the sheet tab of the sheet "calendar"
3) Select "View Code"
4) Paste the code into the window that appears.
5) Save the file as a macro-enabled .xlsm file.
6) Make changes as needed to the cell addresses - as written the dropdown needs to be a DV list on cell C4, and cell A1 will be selected when the monthly sheet is chosen.Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "
C
4" Then Exit Sub
If Target.Value = "" Then Exit Sub
'Turn off events to keep out of loops
Application.EnableEvents = False
With Worksheets(Target.Value)
.Activate
.Range("A1").Select
End With
Application.EnableEvents = True
End Sub
这篇关于下拉菜单链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!