excel - 在特定条件下在用户窗体中显示消息框
问题描述
在此处输入图像描述我有 sheet1 包含 3 列项目、品牌、数量和 userform 在 sheet1 中包含与 textbox1、2、3 相同的元素当我在 userform 中写入数据时我会编写代码向我显示警告消息“你不能添加这个品牌只有 3 或 4...等可用”。
有关显示消息的更多解释取决于 textbox3 示例 sheet1 中的第 3 列包含数量,当我填写 textbox3 多于第 3 列时,然后显示消息。
解决方案
我仍然不完全确定你的意思,但试试这样的
Private Sub TextBox1_AfterUpdate()
'assuming this is the range where the relevant values are'
MaxValu = Application.WorksheetFunction.max(Sheets("Sheet1").Range("C3:C5"))
'change the text box value to an integer'
TxtBoxValu = CInt(Me.TextBox1.Value)
If TxtBoxValu > MaxValu Then MsgBox "this value is too high, the maximum you can
pick is " & MaxValu
End Sub
推荐阅读
- opencv - 检测或拆分网格中的图标
- android - Flutter 本地通知 - 一个声源
- google-apps-script - 如何在保留条件格式的同时移动 Google 表格行?
- javascript - javascript中map()期间如何控制台记录元素值?
- go - 在select语句中,是先使用channel中的缓冲区还是先使用pending queue的值?
- c++ - 为什么概念 C++ 中没有前向声明?
- java - Spring控制器序列化同步
- python - 如何根据 python 中的 if 条件计算极性?
- bayesian - JAGS 中的随机节点数和可识别性
- javascript - 让用户在最短的时间内保持密钥