View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Cancel Input Box error

Hi Garry,

Still cannot get it to work.

Here is the whole code, perhaps that has something to do with it.

Look for the sNum = InputBox is where I need the error check.

The first InputBox you can escape from but not sNum???

Thanks.

Howard


Private Sub botão_procurar_Click()
Dim LRow As Long
Dim aRng As Range, rngFnd As Range
Dim myFnd As String
Dim sNum$


[F6,F8,F10,J10].ClearContents

myIB1:
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
Else
'/ is text and that is okay
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")

'/msgbox show amount of rngFnd
MsgBox "You can pick up to: " & rngFnd.Offset(, 6) & " Stocks for Código I: " _
& vbCr & " " & myFnd _
& vbCr & " " & Range("f8")

myIB2:
sNum = InputBox("Pick no more than " & vbCr & _
" " & rngFnd.Offset(, 6) & " Stocks" & vbCr & "for Código I: " & myFnd & _
" Quantidade Retirada in Cell F10")

'/ ******
' Ok with no entry or Cancel here
'/******

If sNum rngFnd.Offset(, 6) Then
MsgBox "Stock Actual is: " & rngFnd.Offset(, 6) & _
" You are requesting: " & sNum & vbCr & vbCr & _
" Stock Minimo is: " & rngFnd.Offset(, 5)

Sheets("Saídas").Range("F10").ClearContents
GoTo myIB2
'Exit Sub
Else
'/ Continue code
Sheets("Saídas").Range("F10") = sNum
rngFnd.Offset(, 6) = rngFnd.Offset(, 6) - sNum
rngFnd.Offset(, 6).Copy Sheets("Saídas").Range("J10")
End If

End If

End With
End Sub