Limiting input

G

Guest

I have a spreadsheet that users are going to use for supply request at a
county ambulance service. Within this spreadsheet, I am using an inputbox to
obtain the ambulance number (ie M13, M16,M4) for ambulances that need
narcotics replaced. The max number of columns I allow in the spreadsheet is
5. Therefore, I need to limit the max allowable ambulances entered to be 5.
Below, the two lines of code that obtain this info are listed first. This is
followed by a For...Next loop that will ask the quantity for narcotic for
each ambulance.

How do I check to be sure that no more than five ambulances were entered?

ambString = InputBox("Enter ambulance numbers, separated by commas ", , ,
6000, 4500)
ambulances = Split(ambString, ",")
For i = 0 To UBound(ambulances)
'section gets narcotic order for each ambulance
Next i
 
G

Guest

if ubound(ambulances) > 4 then
Msgbox "Too many ambulances entered, quitting"
exit sub
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top