I had implemented the code in, now I am able to compile the program but I'm unable to retrieve any value from it as shown in the attached picture.
and the value does not
May I know where did I put wrong?
Thank you for all the help given!
Attachment 853224 <- no value
Attachment 853228 <- got value for checking
---------- Here is the updated code --------------
Private Sub Execute_Click()
Dim CellValue As String
Dim ValueCheck As String
Dim ItemAvailable As String
Dim QtySubt As String
Dim NameCheck As String
Dim Value1 As Integer, Value2 As Integer, EnoughValue As Integer
ValueCheck = Range("J8") 'Checking for value keyed in (number or text)
ItemAvailable = Range("J7") 'Checking for item availability
NameCheck = Range("H6") 'Checking for username
If ValueCheck = "True" Then
If ItemAvailable = "Yes" Then
Value1 = Range("G11").Value
Value2 = Range("G10").Value
If NameCheck = "True" Then
EnoughValue = Value1 - Value2 'Ensure enough stock in store
If EnoughValue >= 0 Then
CellValue = Range("G12")
MsgBox "The cellvalue Qty is " & CellValue 'Just to check the value (to be remove after everything works)
''============Vlookup code program section=====================================================================================
'Dim longRow As Long
'Dim longRow2 As Long
'
'On Error Resume Next
'longRow = Application.WorksheetFunction.Match(Worksheets("GUI").Range("G7"), Worksheets("MasterList").Range("A:A"), 0)
'longRow2 = Application.WorksheetFunction.Match(Worksheets("GUI").Range("G9"), Worksheets("MasterList").Range("B:B"), 0)
'If Err.Number <> 0 Then
'MsgBox " Search failed"
'Exit Sub
'End If
'On Error GoTo 0
'Worksheets("MasterList").Range("A:A").Cells(longRow, 4) = Sheets("GUI").Range("G12")
''============XLookup code program section=====================================================================================
Dim result As Variant
On Error Resume Next
result = Application.WorksheetFunction.XLookup(Range("G7").Value & Range("G9").Value, Sheets("MasterList").Range("A:A").Value & Sheets("MasterList").Range("B:B").Value, Sheets("MasterList").Range("D:D").Value, "NotFound")
On Error GoTo 0
If Not IsError(result) Then
' Value found, update the balance
CellValue = result
MsgBox "The remaining Qty is " & CellValue
Else
' Value not found
MsgBox "Search failed"
End If
''========================================================================================================
''================================Checking XLoopup to replace Vlookup code program==============================================
'Range("G13").Value = Application.WorksheetFunction.XLookup(Range("G7"), Sheets("MasterList").Range("A:A"), Sheets("MasterList").Range("B:B"), Sheets("MasterList").Range("D:D")) 'working but single lookup
'Range("G14").Value = Application.WorksheetFunction.XLookup(Range("G7" & "G9"), Sheets("MasterList").Range("A:A") & Sheets("MasterList").Range("B:B"), Sheets("MasterList").Range("D:D"))
'Range("G14").Value = Application.WorksheetFunction.XLookup(Range("G7") & Range("G9"), Sheets("MasterList").Range("A:A") & Sheets("MasterList").Range("B:B"), Sheets("MasterList").Range("D:D"), "NotFound")
'Range("G14").Value = Application.WorksheetFunction.XLookup(Range("G7").Value & Range("G9").Value, Sheets("MasterList").Range("A:A").Value & Sheets("MasterList").Range("B:B").Value, Sheets("MasterList").Range("D:D").Value, "NotFound")
'========================================================================================================
'MsgBox "The remaining Qty is " & CellValue
Else
MsgBox "Insufficient Quantity in store"
End If
Else
MsgBox "Please enter a valid name!"
End If
Else
MsgBox "Please enter an valid component"
End If
Else
MsgBox "Please insert a numeric number!"
End If
End Sub
Bookmarks