Help with the code, please

_Fly_

Board Regular
Joined
Jan 6, 2012
Messages
87
Hello my friends, i have this code:

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
myFnd = InputBox("Por favor, introduza o código do artigo que deseja retirar.", "Retirar Material")
doesn't exists on the data base.

Any idea to make the code work?

Thank's on advance.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,216,084
Messages
6,128,722
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top