VBA InputBox without entry quitting Sub/Macro

WumboWunkus

New Member
Joined
Mar 18, 2024
Messages
2
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hi all,

I am working on a module that is designed to allow my users to input values that the script formats and enters into the correct data entry positions. However, I am encountering an issue when a field does not apply and the user tries to hit "ok" to move on, and it ends the sub. I have tried a few different methods for getting past this issue but so far have had 0 success. I welcome any suggestions and thank you for your time in advance!

Here's the mod so far:
VBA Code:
Sub SCARentry()

' Dim Scar # to coman/internal:
Dim scarnum As Double, scardate As String, initiator As String, mednonmed As String, comanint As String

' Dim supplier to pdt code:
Dim supplier As String, suppcontname As String, suppcontemail As String, pdttype As String, pdtcode As String

'Dim pdt description to Vendor Response Date:
Dim pdtdesc As String, procagent As String, procagentcontact As String, vendresponsedate As String

'Dim Extension Request to cost per unit:
Dim extrequest As String, ponum As String, defectquant As Double, nonconfdetails As String, costunit As Double

'Dim Blue sheets to credit expected:
Dim bluesheets As String, casummary As String, materialdisposition As String, creditexpected As String

'Dim open or closed
Dim openclosed As String

Sheets("SCARs 2024").Select
Range("A1").Select

Range("A1").End(xlDown).Offset(1).Select
' Selects end row's first open cell, which contains scar number

    scarnum = InputBox("Enter Scar Number:")
    ActiveCell.Value = scarnum

ActiveCell.Offset(0, 1).Select
'Moves to next cell (date)

    scardate = InputBox("Enter SCAR date:")
    ActiveCell.Value = scardate

ActiveCell.Offset(0, 1).Select
' Moves to next cell, initiator

    initiator = InputBox("Enter the name of the SCAR initiator:")
    ActiveCell.Value = initiator
    
ActiveCell.Offset(0, 1).Select
'Moves to next cell, med/nonmed

    mednonmed = InputBox("Medical or Nonmedical?")
    ActiveCell.Value = mednonmed
    
ActiveCell.Offset(0, 1).Select
'Moves to next cell, coman/internal

    comanint = InputBox("Coman or Internal?")
    ActiveCell.Value = comanint
    
ActiveCell.Offset(0, 1).Select
' Next active cell, supplier name

    supplier = InputBox("Enter the supplier (business) name:")
    ActiveCell.Value = supplier
    
ActiveCell.Offset(0, 1).Select
' Supplier contact name cell

    suppcontname = InputBox("Enter supplier contact/representative's name:")
    ActiveCell.Value = suppcontname

ActiveCell.Offset(0, 1).Select
' Supplier contact email cell

    suppcontemail = InputBox("Enter supplier contact email:")
    ActiveCell.Value = suppcontemail


ActiveCell.Offset(0, 1).Select
' Product type

    pdttype = InputBox("Enter product type (e.g., Packaging):")
    ActiveCell.Value = pdttype

ActiveCell.Offset(0, 1).Select
' Product code

    pdtcode = InputBox("Enter product code:")
    ActiveCell.Value = pdtcode

ActiveCell.Offset(0, 1).Select
'Product description

    pdtdesc = InputBox("Enter product description:")
    ActiveCell.Value = pdtdesc
    
ActiveCell.Offset(0, 1).Select
' PBB MRA, Procurement Agent

    procagent = InputBox("Enter the name(s) of the PBB MRA Procurement Agent:")
    ActiveCell.Value = procagent
    
ActiveCell.Offset(0, 1).Select
'Procurement Agent Contact

    procagentcontact = InputBox("Enter contact information for procurement agent:")
    ActiveCell.Value = procagentcontact

ActiveCell.Offset(0, 1).Select
' Vendor Response Date

    vendresponsedate = InputBox("Enter vendor response date:")
    ActiveCell.Value = vendresponsedate

ActiveCell.Offset(0, 1).Select
' Extension request

    extrequest = InputBox("Extension request? (date or N/A):")
    ActiveCell.Value = extrequest

ActiveCell.Offset(0, 1).Select
'PO number

    ponum = InputBox("Enter purchase order (PO) number:")
    ActiveCell.Value = extrequest

ActiveCell.Offset(0, 1).Select
'Defective quantity

    defectquant = InputBox("Enter the defective quantity (#s only):")
    ActiveCell.Value = defectquant

ActiveCell.Offset(0, 1).Select
'Non-conformance details

    nonconfdetails = InputBox("Enter the details of the non-conformance:")
    ActiveCell.Value = nonconfdetails

ActiveCell.Offset(0, 1).Select
'Cost per unit

    costunit = InputBox("Enter the cost per unit (e.g. 0.0412):")
    ActiveCell.Value = costunit

ActiveCell.Offset(0, 1).Select
'Blue Sheets

    bluesheets = InputBox("Enter Blue Sheets:")
    ActiveCell.Value = bluesheets
    
ActiveCell.Offset(0, 2).Select
'Supplier Corrective Action Summary, skips over total cost (column calculated in sheet)

    casummary = InputBox("Enter supplier corrective action summary:")
    ActiveCell.Value = casummary

ActiveCell.Offset(0, 1).Select
' Material Disposition

    materialdisposition = InputBox("Enter material disposition:")
    ActiveCell.Value = materialdisposition

ActiveCell.Offset(0, 1).Select
'Credit expected (Yes/No)

    creditexpected = InputBox("Is a credit expected (Yes/No)?:")
    ActiveCell.Value = creditexpected
    
ActiveCell.Offset(0, 2).Select
'Open or closed

    openclosed = InputBox("Open or Closed?")
    ActiveCell.Value = openclosed
    
Sheets("Control Panel").Select
'Returns to control panel sheet for next steps
    
MsgBox ("Great! We're done. Remember to check the SCARs 2024 sheet to make sure all information is correct, and edit if needed.")

End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You mean your code raises an error, thus it ends? Likely all you need is to return a zero for a missing input and test for 0.

VBA Code:
initiator = Val(Inputbox("message here"))
If initiator = 0
  ' do something
else
   'do something else
End If
As long as input is only a matter of choosing 1 out of 2 options, why not just use a message box?
Seldom do you need to select cells to make changes to them, but I'll leave that for others who know that subject better.

EDIT - could also just have
If Not initiator = 0 then do something, otherwise don't do it.
 
Upvote 0

Forum statistics

Threads
1,224,733
Messages
6,180,627
Members
452,991
Latest member
JM_000888

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