[VBA]判斷式的應用及參考
x
1r = 12re = Cells(ActiveSheet.Rows.Count, 2).End(xlUp).Row3rs = 945For r = rs To re6'or 的判斷需要將條件寫完整,不能省略等號左邊的條件7 If Cells(r, 7).Value = "新增項目新單價" Or Cells(r, 7).Value = "需議價" Then8'Range的變數要用下列方式呈現9 Range("E" & r & ":F" & r).Select10 Selection.ClearContents11'elseif 跟 and 的格式直接寫就好12 ElseIf Cells(r + 1, 3).Value = "" And Cells(r + 1, 7).Value = "新增項目新單價" Then13 Range("E" & r & ":F" & r).Select14 Selection.ClearContents15 ElseIf Cells(r, 2).Value = "合計" Then16 Range("F" & r).Select17 Selection.ClearContents18'like 可以寫成判斷式。如Cells(r, 4) Like "*單價計*" = true then 這樣19 ElseIf Cells(r, 4) Like "*單價計*" Then20 Range("F" & r).Select21 Selection.ClearContents22 End If23Next
沒有留言:
張貼留言