vue 签名验证,校验数据_数据验证多选编辑

vue 签名验证,校验数据

If you select an item from a data validation drop down list, it's entered in the cell, replacing any existing data in the cell. If you'd like to add more items to the cell, instead of replacing the current text, you can use a bit of programming, to allow multiple selections from a data validation list.

如果从数据验证下拉列表中选择一个项目,则该项目将输入到单元格中,替换该单元格中的所有现有数据。 如果您想向单元格中添加更多项,而不是替换当前文本,则可以使用一些编程,以允许从数据验证列表中进行多项选择

In my sample file that shows how to do this, I've added new code, to prevent a problem that occurs in one type of situation.

在演示如何执行此操作的示例文件中,我添加了新代码,以防止在一种情况下发生问题。

Drop Down List Multiple Entries http://blog.contextures.com/

从下拉列表中选择多个项目 (Select Multiple Items From Drop Down List)

In the screen shot below, you can see the "SameCell" worksheet, in my sample file. There is a data validation drop down list in the active cell.

在下面的屏幕快照中,您可以在示例文件中看到“ SameCell”工作表。 活动单元格中有一个数据验证下拉列表

From that list, "One" was selected, then "Two", and now "Three" will be added. The code remembers the previous contents of the cell, and adds the new selection at the end.

从该列表中,选择“一个”,然后选择“两个”,现在将添加“三个”。 该代码会记住该单元格的先前内容,并在末尾添加新的选择。

multiselectenter01

编辑时的问题 (Problems When Editing)

The multiple selection technique works nicely, unless you try to manually edit the cell. After selecting a couple of items from the drop down list, I clicked in the cell, at the end of the existing text. Then I typed a comma, and "Three".

除非您尝试手动编辑单元格,否则多重选择技术会很好地工作。 从下拉列表中选择几个项目后,我单击了现有文本末尾的单元格。 然后我输入一个逗号,然后输入“三”。

Instead of just adding the new item, the code duplicated all the existing text, and then added then new item, so the result is "One, Two, One, Two, Three".

该代码不只是添加新项目,还复制了所有现有文本,然后又添加了新项目,因此结果是“一个,两个,一个,两个,三个”。

multiselectenter02

允许手动添加 (Allow Manual Additions)

If you want to manually add new items at the end of text in a cell, you can use the code from the "SameCellEnter" sheet in my sample file.

如果要在单元格中的文本末尾手动添加新项目,则可以使用示例文件中“ SameCellEnter”表中的代码。

  • It gets the length of the old entry in the cell, and stores that number in a variable named "lOld".

    它获取单元格中旧条目的长度,并将该编号存储在名为“ lOld”的变量中。
  • Then, it compares that number of character at the left of the new value to old value

    然后,它将新值左侧的字符数与旧值进行比较
  • If those strings are the same, it puts the new value into the cell

    如果这些字符串相同,则将新值放入单元格
  • If those strings are NOT the same, it puts the old value, and a comma, and the new value into the cell

    如果这些字符串不相同,则会将旧值,逗号和新值放入单元格中

Here is the section of code that does the checking:

这是执行检查的代码部分:

If newVal = "" Then
  'do nothing
Else
  lOld = Len(oldVal)
  If Left(newVal, lOld) = oldVal Then
    Target.Value = newVal
  Else
     Target.Value = oldVal _
          & ", " & newVal
  End If
End If

In this example,

在这个例子中

  • oldVal = "One, Two"

    oldVal =“ 一,二

  • lOld=8

    lOld = 8
  • newVal = "One, Two, Three"

    newVal =“ 一,二 ,三”

The first 8 characters at the left of newVal are equal to oldVal, so only the newVal text will be put into the cell after editing.

newVal左侧的前8个字符等于oldVal,因此在编辑后仅newVal文本将被放入单元格中。

multiselectenter04

允许在文本中的任何位置进行编辑 (Allow Edits Anywhere in Text)

The new code on the SameCellEnter sheet works well if you're adding items at the end of the existing text in a cell.

如果要在单元格中现有文本的末尾添加项目 SameCellEnter工作表上的新代码将很好地工作。

If you want to edit the cell's text, or put new entries between existing items, use the code from the "SameCellEdit" sheet in the sample file.

如果要编辑单元格的文本,或在现有项目之间放置新条目,请使用示例文件中“ SameCellEdit”表中的代码。

That sheet has an "Edit Entries" check box that you can click, to turn the macro code on or off. When the code is off, you can edit the cell manually. Then, remove the check mark from the "Edit Entries" check box, to turn the macro back on.

该工作表具有“编辑条目”复选框,您可以单击该复选框以打开或关闭宏代码。 关闭代码后,您可以手动编辑单元格。 然后,从“编辑条目”复选框中删除复选标记,以重新打开宏。

multiselectenter03

获取样本文件 (Get the Sample File)

To get the new code, and other variations, go to the allow multiple selections from a data validation list page on my Contextures website. Download the free sample file there, and this example is on the Same Cell Enter sheet. To see the code, right-click the sheet tab, and click View Code.

若要获取新代码和其他变体,请 Contextures网站上的数据验证列表页面上转到允许多项选择 。 在此处下载免费的示例文件,此示例位于“相同单元格输入”页面上。 要查看代码,请右键单击工作表选项卡,然后单击查看代码。

NOTE: To make data entry even easier, you can buy a copy of my Data Validation Multi Select Premium kit. Use it to build lists that appear in a popup box. The lists can be set up for single selection or multiple selections, and your co-workers don't need the kit in order to use the workbooks that you create.

注意 :为了使数据输入更加容易,您可以购买我的数据验证多选高级工具包的副本。 使用它来构建出现在弹出框中的列表。 可以为单个选择或多个选择设置列表,并且您的同事不需要工具箱即可使用您创建的工作簿。

翻译自: https://contexturesblog.com/archives/2015/10/22/data-validation-multiple-selection-edit/

vue 签名验证,校验数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值