473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Excel inputbox

Hi, I wanted to know if the user input thru excel inputbox can be restricted to limited values.
I am trying to run some analysis on columns with numeric data. But the column has to be input by the user. is there any way by which I can make the inputbox function as a combo box.

Thanks,
nikita
Oct 15 '07 #1
2 1861
kadghar
1,295 Expert 1GB
Hi, I wanted to know if the user input thru excel inputbox can be restricted to limited values.
...
i dont know if that's possible, but you can ask the inputbox to be a double and dont let the user continue until he writes a number in the inputbox.

this little code might be of help:
Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. Dim Dou1 As Double
  3. On Error Resume Next 'ignore the errors
  4. Do
  5.     Dou1 = InputBox("write some number")
  6.     If Err.Number <> 13 Then Exit Do 'err 13 is for data type
  7.     MsgBox "Please enter a numeric value"
  8.     Err.Number = 0 'Clean the error
  9. Loop
  10. On Error GoTo 0 'stop ignoring the errors
  11. End Sub
hth
Oct 15 '07 #2
i dont know if that's possible, but you can ask the inputbox to be a double and dont let the user continue until he writes a number in the inputbox.

this little code might be of help:
Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. Dim Dou1 As Double
  3. On Error Resume Next 'ignore the errors
  4. Do
  5.     Dou1 = InputBox("write some number")
  6.     If Err.Number <> 13 Then Exit Do 'err 13 is for data type
  7.     MsgBox "Please enter a numeric value"
  8.     Err.Number = 0 'Clean the error
  9. Loop
  10. On Error GoTo 0 'stop ignoring the errors
  11. End Sub
hth

Thanks for giving me the start. I could almost get thru (except that i cannot get the look of a combo). Heres the code.

Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. Dim Dou1 As Double
  3. Dim nik As Variant
  4. Dim i As Integer
  5.  
  6. nik = Array(1, 3, 5, 8, 9)
  7. Do
  8.     Dou1 = InputBox("write some number [1/3/5/8/9]")
  9.     For i = LBound(nik) To UBound(nik)
  10.         If Dou1 = nik(i) Then
  11.             MsgBox "Great!"
  12.             End
  13.         End If
  14.     Next i
  15.     MsgBox "Wrong Input!"
  16. Loop
  17. End Sub
Any inputs??
Oct 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jonny | last post by:
Hello, I have created a button on my form which when pressed does the following : 1) Run a pre-defined Macro, which is picking up a query and running my data to excel. However, I need the...
2
by: Aaron | last post by:
I am trying to design an application in Visual Studio that will allow a user to select a spreadsheet, pass in some parameters, and run macros in the spreadsheet that depend on the parameters. I was...
2
by: Agnes | last post by:
I can export the data to an excel(quit slow , for 5k records, It need 20mins) Now, my problem is how can I join another table from another database ? "select I.invno,I.company,C.telno,C.faxno from...
0
by: nixhex | last post by:
Hi, using excel: I'm using data validation / list in my script...and i want it so that if the user selects a specific item from the list box then an Inputbox pops up asking user for more information....
4
by: rnot | last post by:
Hello, I would like to paste data at a cell found by the Selection.Autofilter function. My two first columns hold a "scenario" and "replication" data. I would like upon running a macro to...
0
by: acarrazco | last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined...
2
by: vijayasankarb | last post by:
Hi All, I am developing one application in VBScript which automatically generates excel charts. But, I have a problem here. I need to get the range value(like A1:B50) before calling the...
5
by: Skollie | last post by:
Hi I need help to activate the cancel button in input box to do the comaand "EXIT" in macro here is the macro and no case sensitvityin inputboxes pls tanks Sub Auto_Open() Dim Name As String Dim...
1
by: helraizer1 | last post by:
Hi folks, I am making a spreadsheet for a foreign exchange bureau, on the loading of the page it asks the operator to add the day's exchange rates. I have the following code in Excel VBA ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.