Hello my friends, i have this code:
But the way i have created the code:
doesn't run.
This MsgBox must appear if the number inserted on the
Any idea to make the code work?
Thank's on advance.
Private Sub botão_procurar_Click()
Dim LRow As Long
Dim aRng As Range, rngFnd As Range
Dim myFnd As String
Dim myPut As String
Dim myPut2 As String
myIB:
myFnd = InputBox("Por favor, introduza o código do artigo que deseja retirar.", "Retirar Material")
If myFnd = "" Then
Exit Sub
ElseIf IsNumeric(myFnd) Then
myFnd = Val(myFnd) '/ converts a "text" number to a value
End If
With Sheets("Registos Globais")
LRow = Sheets("Registos Globais").Cells(Rows.Count, "A").End(xlUp).Row
Set rngFnd = Sheets("Registos Globais").Range("A2:A" & LRow).Find(What:=myFnd, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not rngFnd Is Nothing Then
rngFnd.Copy Sheets("Saídas").Range("F6")
rngFnd.Offset(, 2).Copy Sheets("Saídas").Range("F8")
rngFnd.Offset(, 7).Copy Sheets("Saídas").Range("f12")
rngFnd.Offset(, 6).Copy Sheets("Saídas").Range("J10")
Sheets("Saídas").Range("F10").Select
myIB2:
myPut = InputBox("O Stock Actual de " & Range("F8") & " é de " & rngFnd.Offset(, 6) & " unidade(s)." & vbCrLf & "Qual a quantidade que deseja retirar?", "Retirar Material")
Range("F10").Value = myPut
If myPut = "" Then
Sheets("Saídas").Select
Range("f6:g6").ClearContents
Range("f8:n8").ClearContents
Range("j10").ClearContents
Range("f12").ClearContents
Range("f10").ClearContents
Exit Sub
End If
If Sheets("Saídas").Range("F10") > rngFnd.Offset(, 6) Then
myPut2 = MsgBox("O Stock Actual de " & Range("F8") & " é de " & rngFnd.Offset(, 6) & " unidade(s)." & vbCrLf & "No entanto você deseja retirar " & Sheets("Saídas").Range("F10") & " unidade(s)." & vbCr & "Por favor introduza um valor igual ou inferior a " & rngFnd.Offset(, 6) & " unidade(s).", vbExclamation, "Retirar Material")
GoTo myIB2
Else
MsgBox "Não foi encontrado nenhum artigo com esse código!" & vbCrLf & _
"Por favor, tente novamente.", vbExclamation, "Retirar Material"
GoTo myIB
End If
End If
End With
End Sub
But the way i have created the code:
Else
MsgBox "Não foi encontrado nenhum artigo com esse código!" & vbCrLf & _
"Por favor, tente novamente.", vbExclamation, "Retirar Material"
GoTo myIB
doesn't run.
This MsgBox must appear if the number inserted on the
doesn't exists on the data base.myFnd = InputBox("Por favor, introduza o código do artigo que deseja retirar.", "Retirar Material")
Any idea to make the code work?
Thank's on advance.