ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to restart a code upon vbno (https://www.excelbanter.com/excel-discussion-misc-queries/222715-how-restart-code-upon-vbno.html)

FARAZ QURESHI

How to restart a code upon vbno
 
I have the following piece of code and want to restart the procedure if the
user inserts nothing OR zero in the first inputbox and then clicks "No" on
the proceeding MsgBox.

Please highlight, what is wrong with the code?

Public Sub CNV()
Dim check12 As Double
check12 = Application.INPUTBOX (prompt:="Input Dollar Conversion Rate",
Type:=1)
If check12 Is Nothing Then
fb = MsgBox("You have not inserted anything. You want to continue?",
vbYesNo)
If fb = vbYes Then
ActiveCell = "=A1*" & check
Else: GoTo check12
End If
End If
End Sub

--
Best Regards,
FARAZ A. QURESHI

curlydave

How to restart a code upon vbno
 
Try this
Sub CNV()
Dim c As Integer
On Error GoTo ExitProc
c = InputBox("Enter Value")
ActiveCell = "=A1*" & c
Exit Sub
ExitProc:
fb = MsgBox("You have not inserted anything. You want to
continue?", vbYesNo)
If fb = vbYes Then CNV
If fb = vbNo Then Exit Sub

End Sub


FARAZ QURESHI

How to restart a code upon vbno
 
XCLENT!
By the way upon entering Zero the code continues. How 2 insert an OR
condition to check whether the No value or Zero was inserted?
--

Best Regards,
FARAZ A. QURESHI


"CurlyDave" wrote:

Try this
Sub CNV()
Dim c As Integer
On Error GoTo ExitProc
c = InputBox("Enter Value")
ActiveCell = "=A1*" & c
Exit Sub
ExitProc:
fb = MsgBox("You have not inserted anything. You want to
continue?", vbYesNo)
If fb = vbYes Then CNV
If fb = vbNo Then Exit Sub

End Sub




All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com