返回列表 上一主題 發帖

[發問] 輸入某區域,會跳出提示晝面?

回復 1# metrostar
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2. If Intersect(Target, [D3:D8]) Is Nothing Or Target.Count <> 1 Then Exit Sub
  3. If Application.Sum([D3:D8]) < 510 Then msg = "數值總和差 " & 510 - Application.Sum([D3:D8])
  4. If Target Mod 1 <> 0 Then msg = "只能輸入整數": fs = True
  5. If Application.Sum([D3:D8]) > 510 Then msg = "數值最大只能輸入 " & 510 - Application.Sum([D3:D8]) + Target: fs = True
  6. If Target < 0 Or Target > 255 Then msg = "數值只能介於0~255": fs = True
  7. If msg <> "" Then MsgBox msg
  8. If fs = True Then Target.Select
  9. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 地上種了菜,就不易長草;心中有善,就不易生惡。
返回列表 上一主題