如何在Excel中用所有工作表名称填充用户窗体组合框?
本文讨论的是将当前工作簿的所有工作表名称填充到Excel中的用户窗体组合框中。
使用VBA代码用所有工作表名称填充Userform ComboBox
使用VBA代码用所有工作表名称填充Userform ComboBox
惊人的! 在 Excel 中使用高效的选项卡,如 Chrome、Firefox 和 Safari!
每天节省50%的时间,并减少数千次鼠标单击!
下面的VBA代码可以帮助您将当前工作簿的所有工作表名称插入到用户窗体组合框中。 请执行以下操作。
1。 按 其他 + F11 同时打开 Microsoft Visual Basic应用程序 窗口。
2.在 Microsoft Visual Basic应用程序 窗口,请点击插入用户表单 插页 > 用户表格 如下图所示。
3.然后绘制一个组合框控件并将其插入用户窗体。 看截图:
4.右键单击插入的组合框,然后选择 查看代码 从上下文菜单中。 看截图:
5.在开幕 Microsoft Visual Basic应用程序 窗口,请复制并粘贴以下VBA代码以替换“代码”窗口中的原始代码。
VBA代码:使用当前工作簿的所有工作表名称填充用户窗体组合框
Private Sub UserForm_Initialize()
Dim I As Long
Me.ComboBox1.Clear
For I = 1 To Sheets.Count
Me.ComboBox1.AddItem Sheets(I).Name
Next
Me.ComboBox1.Value = ActiveSheet.Name
End Sub
Note: In the code, ComboBox1 is the name of the inserted Combo Box. Please change it to the one of your own.
6. Press the F5 key to run the code. In the opening Userform, you can see all sheet names of the current workbook are displaying in the combo box as below screenshot:
Easily list all sheet names in Excel
The Create List of Sheet Names utility of Kutools for Excel can help to easily list all worksheet names of active workbook in a new worksheet in Excel. And you can shift to corresponding worksheet directly with clicking on the sheet name as the below screenshot shown. Download and try it now! (30-day free trail)
Related Articles:
How to copy Combo Box value to active cell in Excel?
How to display date format in combo box output in Excel?
How to open a specific worksheet by the selected value of a Combo Box in Excel?
How to prevent or disable typing in a combo box in Excel?
How to tab out of combo box to select specific cell in Excel?
Best Office Productivity Tools
Transform Hours into Minutes with Kutools for Excel!
Ready to supercharge your Excel tasks? Harness the power of Kutools for Excel - your ultimate time-saving tool. Streamline intricate tasks and glide through your data like a pro. Experience Excel at lightning speed!
Why You Need Kutools for Excel
🛠️ Over 300 Powerful Features: Kutools is packed with more than 300 advanced features, simplifying your work in over 1500 scenarios.
📈 Superior Data Processing: Merge cells, remove duplicates, and perform advanced data conversions – all without breaking a sweat!
⏱️ Efficient Batch Operations: Why put in extra effort when you can work smart? Import, export, combine, and tweak data in bulk with ease.
📊 Customizable Charts and Reports: Access a broad variety of additional charts and generate insightful reports that tell a story.
🗄️ Powerful Navigation Pane: Gain an advantage with the robust Column Manager, Worksheet Manager, and Custom Favorites.
📝 Seven Types of Drop-down Lists: Make data entry a breeze with drop-down lists of various features and types.
🎓 User-Friendly: A breeze for beginners and a powerful tool for experts.
Download Now and Soar Through Time with Excel!
Read More... Free Download... Purchase...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
Open and create multiple documents in new tabs of the same window, rather than in new windows.
Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Read More... Free Download... Purchase...
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。