Advertisement
YasserKhalil2019

T3942_Change Price By ComboBox OptionButtons

Sep 19th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. https://excel-egy.com/forum/t3942
  2. ---------------------------------
  3.  
  4. Dim x, y
  5.  
  6. Private Sub ComboBox1_Change()
  7. x = Application.Match(ComboBox1.Value, Columns(1), 0)
  8. If ComboBox1.Value = "" Then TextBox1.Value = ""
  9.  
  10. If OptionButton1.Value = True Then OptionButton1_Click
  11. If OptionButton2.Value = True Then OptionButton2_Click
  12. End Sub
  13.  
  14. Private Sub ComboBox3_Change()
  15. y = Application.Match(ComboBox3.Value, Columns(1), 0)
  16. If ComboBox3.Value = "" Then TextBox4.Value = ""
  17.  
  18. If OptionButton1.Value = True Then OptionButton1_Click
  19. If OptionButton2.Value = True Then OptionButton2_Click
  20. End Sub
  21.  
  22. Private Sub OptionButton1_Click()
  23. If ComboBox1.Value = "" Then TextBox1.Value = "": GoTo Skipper1
  24. If IsError(x) Then GoTo Skipper1
  25.  
  26. If OptionButton1.Value = True Then
  27. OptionButton2.Value = False
  28. TextBox1.Value = Range("C" & x).Value
  29. End If
  30.  
  31. Skipper1:
  32. If ComboBox3.Value = "" Then TextBox4.Value = "": GoTo Skipper2
  33. If IsError(y) Then GoTo Skipper2
  34.  
  35. If OptionButton1.Value = True Then
  36. OptionButton2.Value = False
  37. TextBox4.Value = Range("C" & y).Value
  38. End If
  39.  
  40. Skipper2:
  41. End Sub
  42.  
  43. Private Sub OptionButton2_Click()
  44. If ComboBox1.Value = "" Then TextBox1.Value = "": GoTo Skipper1
  45. If IsError(x) Then GoTo Skipper1
  46.  
  47. If OptionButton2.Value = True Then
  48. OptionButton1.Value = False
  49. TextBox1.Value = Range("D" & x).Value
  50. End If
  51.  
  52. Skipper1:
  53. If ComboBox3.Value = "" Then TextBox4.Value = "": GoTo Skipper2
  54. If IsError(y) Then GoTo Skipper2
  55.  
  56. If OptionButton2.Value = True Then
  57. OptionButton1.Value = False
  58. TextBox4.Value = Range("D" & y).Value
  59. End If
  60.  
  61. Skipper2:
  62. End Sub
  63.  
  64. Private Sub CommandButton1_Click()
  65. TextBox3.Value = TextBox2.Value * TextBox1.Value
  66. TextBox6.Value = TextBox5.Value * TextBox4.Value
  67. TextBox7.Value = Val(Val(TextBox6.Value) + Val(TextBox3.Value))
  68. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement