根据其它字段的值来决定自己是否为下拉框
2009-01-06 17:13
141 查看
'BP Type为Dist时,Product/Metric列为下拉列表1、Shipped REV ($k), 2、Sell Thru Units, 3、WOS
'否则还是普通的文本框
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'首先判断被选择的是不是Product/Metric,并且判断BP Type的值是不是Dist
If Target.Column = 6 And Cells(Target.Row, 4).Value = "3 Dist" Then
'如果是,则将Product/Metric设为下拉框,并添加数据
With Cells(Target.Row, 6).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="1、Shipped REV ($k), 2、Sell Thru Units, 3、WOS"
.IgnoreBlank = False
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
Else
'如果不是,则将Product/Metric置为普通文本框
With Cells(Target.Row, 6).Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
End If
End Sub
IF 和Else里的代码表示把某列设为下拉框或普通文本框,是通过录制宏的方式得到的,比较简单
'否则还是普通的文本框
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'首先判断被选择的是不是Product/Metric,并且判断BP Type的值是不是Dist
If Target.Column = 6 And Cells(Target.Row, 4).Value = "3 Dist" Then
'如果是,则将Product/Metric设为下拉框,并添加数据
With Cells(Target.Row, 6).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="1、Shipped REV ($k), 2、Sell Thru Units, 3、WOS"
.IgnoreBlank = False
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
Else
'如果不是,则将Product/Metric置为普通文本框
With Cells(Target.Row, 6).Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
End If
End Sub
IF 和Else里的代码表示把某列设为下拉框或普通文本框,是通过录制宏的方式得到的,比较简单
相关文章推荐
- Oracle - EBS: SQL&PL/SQL 如何根据flag参数决定是否按照某些字段group分组
- 让UILabel根据内容字体的多少,来决定自己的高度
- 这个网站的的,首页有特点。它能根据浏览器是否支持HTML5或者是Silverlight,来决定是启用HTML5的Video还是Silverlight播放视频。
- [QualityCenter]设置工作流脚本-根据某字段是否包含指定字符串来判断其他字段的选值
- Android根据用户设置决定是否在开机时启动应用程序
- win32 api ShouCursor 根据内部计数器 是否>= 0 决定是否 显示光标,每true时计数器+1,每false-1
- 怎么去证明自己的思想是否正确:按照思想的指引去做事,然后根据结果来判定。
- Android根据用户设置决定是否在开机时启动应用程序
- 相同name,取最小的id的值,mysql根据相同字段 更新其它字段
- 根据radio判断下拉框是否禁用
- SQL技巧两则:选择一个表的字段插入另一个表,根据其它表的字段更新本表内容
- 2017.5.27 使用propagation实现:根据参数决定是否需要事务管理
- 今天你为自己贴上什么样的标签,或许就决定了明天你是否会被委以重任
- 使用spring声明式事务,spring使用AOP来支持声明式事务,会根据事务属性,自动在方法调用之前决定是否开启一个事务,并在方法执行之后决定事务提交或回滚事务。
- cassandra——可以预料的查询,如果你的查询条件有一个是根据索引查询,那其它非索引非主键字段,可以通过加一个ALLOW FILTERING来过滤实现
- SQL语句二次排序。先根据是否置顶字段。再根据最后更新时间排序。
- jQuery Easy UI中根据第一个下拉框选中的值设置第二个下拉框是否可以编辑
- 根据radiobutton的选择决定dropdownlist是否禁用
- 根据物料单位决定是否去掉小数点!(航发项目)
- 表单提交前根据用户的选择决定是否提交