Sub UpdateYieldPercentage()
'declare the variables
Dim Item As String, Percent As Long
'error handling
On Error GoTo ErrHandler:
'hold in memory and stop screen flicker
Application.ScreenUpdating = False
'set variables
Item = Sheet1.Range("P11").Value
Percent = Sheet1.Range("Q13").Value
'check for values
If Item = vbNullString Or Percent = 0 Then
MsgBox "Select a product to update"
Exit Sub
End If
'find the row to edit - Column D holds the values of a data validation list in cell P11
fRow = Application.Match(Item, Sheet2.Columns(4), 0)
Sheet2.Cells(fRow, 9).Value = Percent
MsgBox "Yield % for " & Item & " updated", vbOKOnly, "YIELD % UPDATE"
Sheet1.Range("P11").Value = vbNullString ' Here I was to clear the cells on the dashboard (Sheet1)
Sheet1.Range("Q13").Value = vbNullString
Exit Sub
ErrHandler:
'show error information in a messagebox
MsgBox "An Error has Occurred " & vbCrLf & _
"The error number is: " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & "Please notify Chef Jamie"
Application.ScreenUpdating = True
End Sub
Bookmarks