返回列表 上一主題 發帖

IF...判斷加總問題

回復 10# 074063

試試看吧!
    Book1x.rar (16.47 KB)

TOP

回復 11# lpk187


    讚!測試沒問題,vba寫法大致上都了解 :D
 
 感謝大大不勝其煩的指導 ^__^

TOP

回復 11# lpk187


    不好意思, 請問一下大大為什麼誤KEY IN資料在12列以上也會運算呢

TOP

回復 13# 074063


    誤KEY IN資料在12列以上也會運算呢
不懂?你原公式不是大於12列以上都要運算嗎?

TOP

回復 14# lpk187


    應該是說12列以下...>< Book1x.rar (15.1 KB)

TOP

回復 15# 074063

這樣再試試
    Book1x.rar (16.27 KB)

TOP

回復 16# lpk187


    請問..這些是代表什麼
    Target.Row > 11 And Target.Column = 18 Or _
    Target.Row > 11 And Target.Column = 20 Or _
    Target.Row > 11 And Target.Column = 21 Then
    aa = Target.Row
    aa1 = Target.Column

TOP

回復 17# 074063

請參考VBA說明:Worksheet.Change 事件
及善用區域變數視窗觀看,就知道那是什麼意思了!

TOP

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r&, t$, c
With Target
  If .Count > 1 Or .Row < 12 Then Exit Sub Else r = .Row
  If Application.Mode(Array(.Column, 7, 18, 20, 21, 0, 0)) = 0 Then Exit Sub
End With

On Error GoTo 1
Application.EnableEvents = False
If Cells(r, "G") = "" Then Cells(r, "V").Resize(1, 3) = "": GoTo 1

Cells(r, "V") = Cells(r, "R") + Cells(r, "T") + Cells(r, "U")
Cells(r, "W") = Cells(r, "G") - Cells(r, "V")
If Cells(r, "W") = 0 Then t = "結": c = 41
If Cells(r, "V") > Cells(r, "G") Then t = "資料錯誤": c = 0

Cells(r, "X") = t
Cells(r, "X").Font.ColorIndex = c
1: Application.EnableEvents = True
End Sub

TOP

        靜思自在 : 要用心,不要操心、煩心。
返回列表 上一主題