excel导⼊数据校验_从Excel数据验证列表中选择多个项⽬excel导⼊数据校验
You've probably used an , where you can click the arrow, and select an item to fill the cell. With a bit of programming, you can customize a drop down list, to select multiple items.
您可能已经使⽤了 ,您可以在其中单击箭头,然后选择⼀个项⽬来填充单元格。 通过⼀些编程,您可以⾃定义下拉列表,以选择多个项⽬。
单选下拉 (Single Selection Drop Down)
By default, data validation drop downs only allow you to select one item.
默认情况下,数据验证下拉列表仅允许您选择⼀项。
In the worksheet shown below, you can select a month from the drop down, and it overwrites any previous selection in that cell.
在下⾯显⽰的⼯作表中,您可以从下拉菜单中选择⼀个⽉,它会覆盖该单元格中以前的所有选择。
从下拉列表中选择多个项⽬ (Select Multiple Items From the Drop Down List)
Instead of limiting users to a single selection, you can use a bit of programming, combined with the data validation list, and allow multiple selections.
您可以使⽤⼀些编程,再结合数据验证列表,⽽不是将⽤户限制为单个选择,并允许多个选择。
You can display all the selected items across a row, or down a column, or keep them in the same cell. Keep reading, to see some examples of this technique, and how it works.
您可以在⼀⾏或⼀列中显⽰所有选定的项⽬,或将它们保留在同⼀单元格中。 继续阅读,以查看该技术的⼀些⽰例以及其⼯作⽅式。
There is also a video that shows the multiple selection drop down list. To try it for yourself, follow the download link for the sample file, near the end of this article.
还有⼀个视频,显⽰多选下拉列表。 若要⾃⼰尝试,请遵循本⽂末尾的⽰例⽂件的下载链接。
有关选择多个项⽬的更多⽂章 (More Articles on Select Multiple Items)
[Update]: Since posting this article on selecting multiple items from an Excel drop down list, I've added more articles on this topic. Here are a few links to updates:
[更新]:⾃从发布有关从Excel下拉列表中选择多个项⽬的⽂章以来,我已经添加了有关此主题的更多⽂章。 以下是⼀些更新链接:
how to
如何
数据验证怎么设置下拉菜单cells
单元格
in multiple selection column
在多个选择列中
from an Excel drop down list
从Excel下拉列表中
You can find the full list on the main page for this technique:
您可以在主页上到此技术的完整列表:
多种选择选项 (Multiple Selection Options)
In the sample file, there are different examples of the code, with options for where the selected items are placed. You might want all the items in a single cell, or in adjacent rows or columns.
在⽰例⽂件中,有不同的代码⽰例,以及⽤于放置所选项⽬的选项。 您可能希望所有项⽬都在单个单元格中,或者在相邻的⾏或列中。
跨⾏填充 (Fill Across a Row)
For example, each item selected in this drop down list fills the next empty cell at the right. You could use this technique to fill player names across a list of innings, or employee names for days of the week.
例如,在此下拉列表中选择的每个项⽬将填充右侧的下⼀个空⽩单元格。 您可以使⽤此技术在局列表中填充玩家名称,或在⼀周中的某天填充员⼯名称。
填写⼀栏 (Fill Down a Column)
In some worksheets, you might prefer to fill down, instead of across.
在某些⼯作表中,您可能更愿意填写⽽不是全部填写。
将值添加到同⼀单元格 (Add Values To the Same Cell)
Instead of filling other cells, you can keep all the selections in the same cell, separated by commas.
不必填充其他单元格,⽽是可以将所有选择保留在同⼀单元格中,并⽤逗号分隔。
使⽤编程来添加多个值 (Use Programming to Add Multiple Values)
The code to allow multiple selections runs automatically when you make a change on the worksheet. To see the code for the SameCell sheet, in the sample file, you can right-click the sheet tab, and click on View Code.
当您在⼯作表上进⾏更改时,允许多项选择的代码将⾃动运⾏。 要查看SameCell⼯作表的代码,请在⽰例⽂件中右键单击⼯作表选项卡,然后单击“查看代码”。
In the code shown below, column 3 is the only one where the change will occur. In your workbook, you could change the 3 to a different number.
在下⾯显⽰的代码中,第3列是唯⼀会发⽣更改的地⽅。 在⼯作簿中,您可以将3更改为其他数字。
Or, if you don't want to limit the code to a specific column, you could delete the two rows that are marked with a red circle.
或者,如果您不想将代码限制为特定的列,则可以删除标有红⾊圆圈的两⾏。
下载样本数据验证⽂件 (Download the Sample Data Validation File)
To experiment with this technique, you can download the zipped sample file from the Contextures website, on the page.
若要试验此技术,可以从Contextures⽹站的“ 页上下载压缩的⽰例⽂件。
NOTE: In some of the code, you might have to change the range names or the sheet names, if you copy the code to a different workbook. Some code examples refer to a specific row or column number, and you might also need to adjust those.
注意:在某些代码中,如果您将代码复制到其他⼯作簿中,则可能必须更改范围名称或⼯作表名称。 ⼀些代码⽰例引⽤了特定的⾏号或列号,您可能还需要对其进⾏调整。
In the sample file, a macro runs automatically when the workbook opens, to protect the "SameCell" worksheet. If you do not need that code, you can remove it from the ThisWorkbook module.
在⽰例⽂件中,当⼯作簿打开时,宏会⾃动运⾏,以保护“ SameCell”⼯作表。 如果不需要该代码,可以将其从ThisWorkbook模块中删除。
If you remove or rename the SameCell sheet, without deleting the Workbook_Open code, you will see an error message when the file opens.
如果删除或重命名SameCell⼯作表,⽽不删除Workbook_Open代码,则在打开⽂件时会看到错误消息。
购买⾼级版 (Buy the Premium Version)
There is a premium version of this technique, and you can see the details here: . Instead of selecting from the drop down, a list box appears when you click the cell. It automatically selects any items that are already in the cell. It also has buttons to Clear all the selections, and select all the items.
该技术有⼀个⾼级版本,您可以在此处查看详细信息: 。 单击该单元格时,会出现⼀个列表框,⽽不是从下拉列表中进⾏选择。 它会⾃动选择单元格中已经存在的所有项⽬。 它还具有清除所有选择并选择所有项⽬的按钮。
The premium version works with dependent lists too, and runs on a protected worksheet. There is also an option of showing a multi-select listbox, or a single-select version (this is helpful when working with dependent lists -- you don't want multiple items selected in the main columns).
⾼级版本也可⽤于从属列表,并在受保护的⼯作表上运⾏。 还有⼀个显⽰多选列表框或单选版本的选项(这在处理从属列表时很有⽤-您不希望在主列中选择多个项⽬)。
The kit has 3 sample files, and a user guide, with details and screen shots, on how to add this technique to your own workbooks. Click here for details: .
该⼯具包包含3个⽰例⽂件和⼀个⽤户指南,其中包含有关如何将此技术添加到您⾃⼰的⼯作簿中的详细信息和屏幕截图。 单击此处了解详细信息: 。
观看数据验证视频 (Watch the Data Validation Video)
To see these techniques, and a few other multiple selection examples, you can watch this short video.
要查看这些技术以及其他⼀些选择⽰例,您可以观看此简短视频。
excel导⼊数据校验
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论