很简单,类似:
If Range("L58") = "Sigma Network" And Range("M58") = "" Then
Range("M58").Value = InputBox("Please enter cable length ", "Input value!", 0)
End If
你当然需要额外的逻辑来防止用户输入一个0值或空字符串,等等,
如果你正在做此上,例如,50个不同的对细胞,(比方说L58至L107和M58至M107例如),这是,你可以使用一个基本的环结构:
Dim cl as Range
For Each cl in Range("L58:L107")
If cl.Value = "Sigma Network" and cl.Offset(0,1).Value = "" Then
cl.Offset(0,1).Value = GetValue("Please enter cable length ", "Input value!", 0)
End If
Next
环路可以进一步缩小d(例如,如果“Sigma网络”不是您检查的唯一东西,或者您需要根据其他一些条件为输入框输入不同的消息文本等。
这将需要定制GetValue
功能,该功能调用InputBox
提示,并配置为防止用户输入0值。可能需要额外的逻辑来防止其他类型的数据输入。
Function GetValue(msg as String, _
Optional title as String = "", _
Optional default as Double = 0)
'Function that calls the InputBox method
Dim ret
Do Until ret <> 0
ret = InputBox(msg, title, default)
Loop
GetValue = ret
End Function
*有人知道我在宏中缺少什么吗?我不会发布整个剧本,因为它很长...... * ** << **这两个声明似乎彼此不一致。这里没有人能读懂你的想法...... –
你可能不想使用'MsgBox'来使用'InputBox'并将返回值赋给'Range(“M58”)',但这只是一个猜测。 –
它是完全相同的脚本,但不同的单元格。所以L55,L56,L57等我不认为有必要看到50个相同的东西。 – Sherri