Hi
I need adapting this code by add message box if I fill number in textbox4 under ENTERING bigger or small than textbox3 under NET
example:
select item from combobox1 and will populate numbers textbox1:textbox3 , textbox3 =200 .pic1 : when I enter number in textbox4 =500
then messagebox " the only available QTY is 200 , so you should wait to arrive 300 qty in next orders "and should just fill 200 in textbox4 after massage box is gone .
300 is got by (500-200=300)
pic2: if textbox3=0 and textbox4 =200 then message box "there is no available QTY for this brand",so you should wait to arrive 200 qty in next orders" and textbox4=0 after massage box is gone
200is got by (200-0=200)
pic3: if textbox3 is minus =-100 and textbox4=200 then message box "there is no available QTY for this brand ,so you should wait to arrive 300 qty in next orders " and textbox4=0 after massage box is gone
300 is got by (200-(-100)=300)
I hope this clear
thanks
I need adapting this code by add message box if I fill number in textbox4 under ENTERING bigger or small than textbox3 under NET
VBA Code:
Private Sub ComboBox1_Change()
Dim ws As Worksheet
Dim lr As Long, c As Long, i As Long
Dim qty As Double
i = 1: c = 4
If Me.ComboBox1.Value <> "" Then
For Each ws In ThisWorkbook.Worksheets(Array("ORDERS", "STOCK"))
lr = ws.Cells(ws.Rows.Count, c).End(xlUp).Row
qty = WorksheetFunction.SumIf(ws.Cells(2, c).Resize(lr), Me.ComboBox1.Value, ws.Cells(2, c + 1).Resize(lr))
Me.Controls("TextBox" & i).Text = qty
i = 2: c = 2
qty = 0
Next ws
End If
TextBox3.Value = Val(TextBox2.Value) - Val(TextBox1.Value)
End Sub
example:
select item from combobox1 and will populate numbers textbox1:textbox3 , textbox3 =200 .pic1 : when I enter number in textbox4 =500
then messagebox " the only available QTY is 200 , so you should wait to arrive 300 qty in next orders "and should just fill 200 in textbox4 after massage box is gone .
300 is got by (500-200=300)
pic2: if textbox3=0 and textbox4 =200 then message box "there is no available QTY for this brand",so you should wait to arrive 200 qty in next orders" and textbox4=0 after massage box is gone
200is got by (200-0=200)
pic3: if textbox3 is minus =-100 and textbox4=200 then message box "there is no available QTY for this brand ,so you should wait to arrive 300 qty in next orders " and textbox4=0 after massage box is gone
300 is got by (200-(-100)=300)
I hope this clear
thanks