[英]Combining 3 Private Sub Worksheet_Change
我是第一次發帖,也是 VBA 的新手。所以我希望我說得通:)我正在嘗試組合 3 個私人潛艇,但不確定如何將它們編碼在一起。
我有一個具有數據驗證功能的電子表格,我希望根據所選內容顯示一個輸入框。
在“I”列是第一組數據驗證,有接受,拒絕和Null無效的選項,如果“接受”則沒有,但如果拒絕或無效的Null,我希望出現一個彈出框用戶輸入 $0,並將其傳遞到“D”列
在“M”列中是下一個用於數據驗證的列,唯一的選項是空白和完整。 如果空白則什么都沒有,但如果完成,我想彈出一個窗口供用戶輸入報價值,然后將其傳遞到“D”列。
先感謝您。
這是我的代碼
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("I:I")) Is Nothing Then
If Target = "Declined" Then
roww = Target.Row
Application.EnableEvents = False
Cells(roww, "D").Value = Application.InputBox(Prompt:="Updated quoted value to 0", Type:=2)
Application.EnableEvents = True
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("I:I")) Is Nothing Then
If Target = "Null in Void" Then
roww = Target.Row
Application.EnableEvents = False
Cells(roww, "D").Value = Application.InputBox(Prompt:="Updated quoted value to 0", Type:=2)
Application.EnableEvents = True
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("M:M")) Is Nothing Then
If Target = "Complete" Then
roww = Target.Row
Application.EnableEvents = False
Cells(roww, "D").Value = Application.InputBox(Prompt:="Updated quoted value to the Quotation Value", Type:=2)
Application.EnableEvents = True
End If
End If
End Sub
Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("M:M")) Is Nothing Then
If Target = "Complete" Then
roww = Target.Row
Application.EnableEvents = FALSE
Cells(roww, "D").Value = Application.InputBox(Prompt:="Updated quoted value To the Quotation Value", Type:=2)
Application.EnableEvents = TRUE
End If
ElseIf Not Intersect(Target, Range("I:I")) Is Nothing Then
If Target = "Declined" Then
roww = Target.Row
Application.EnableEvents = FALSE
Cells(roww, "D").Value = Application.InputBox(Prompt:="Updated quoted value To 0", Type:=2)
Application.EnableEvents = TRUE
ElseIf Target = "Null in Void" Then
roww = Target.Row
Application.EnableEvents = FALSE
Cells(roww, "D").Value = Application.InputBox(Prompt:="Updated quoted value To 0", Type:=2)
Application.EnableEvents = TRUE
End If
End If
End Sub
請參閱此官方文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.