PDA

View Full Version : assistance from experts to fixing theses codes



abdelfattah
07-27-2021, 04:01 AM
hi
when I search in the internet like my question . I 've found theses codes but there is something . it doesn't work
the idea of code shows message when fill values in textbox1 after fill combobox1,2,3 they should match with col A,B,C if the values are filled in textbox1,2 bigger than what are existed in col D then should message box the value is exceeded and show the real value for specific item . so if any body can fix it or alternative code it will be a great





Function MatchingRowNumber(Brand As String, _
Typ As String, _
Origin As String) As Long
' 290


Dim Fun As Long


With Worksheet("List")
' search for the match here
' Fun interim result
End With
MatchingRowNumber = Fun
End Function


Private Function IsAvailable(ByVal Qty As Long) As Boolean
' 290


Dim R As Long
Dim AvailQty As Long


R = MatchingRowNumber(ComboBox1.Value, _
ComboBox2.Value, _
ComboBox3.Value)
AvailQty = List.Cells(R, "D").Value
If AvailQty < Qty Then
MsgBox "The quantity you entered exceeds availability." & vbCr & _
"Available quantity is " & AvailQty & ".", _
vbInformation, "Limited availability"
Else
IsAvailable = True
End If
End Function


Private Sub TextBox1_Change()
' 290


If IsAvailable(TextBox1.Value) Then
' continue with the program
Else
' return to the textbox
TextBox1.SetFocus
End If
End Sub

Paul_Hossler
07-27-2021, 08:37 AM
It's much easier to help if you attach a small sample workbook with some data and the existing macros

abdelfattah
07-28-2021, 01:15 AM
thanks for your interesting
there is another code . it copies data from userform to sheet INV , but I want before copy data . it should check the values are existed in COL D in sheet LIST if the item contain value into textbox1 or 2 bigger than what are existed in COL D in sheet LIST then should show message the number is exceeded and show me the real qty is available .

abdelfattah
08-12-2021, 11:55 AM
is there any help?

snb
08-13-2021, 12:16 AM
Why don't you show the user the availabe stock before (s)he can choose an amount ?
Why don't you restricht the user's choice to the available stock ?