ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Limiting input (https://www.excelbanter.com/excel-programming/382667-limiting-input.html)

WLMPilot

Limiting input
 
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

Tom Ogilvy

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

--
Regards,
Tom Ogilvy


"WLMPilot" wrote:

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



All times are GMT +1. The time now is 01:41 PM.

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