ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validating user input to a listbox (https://www.excelbanter.com/excel-programming/276213-validating-user-input-listbox.html)

Stuart[_5_]

Validating user input to a listbox
 
I've a 2 col multicolumn listbox. Col1 holds values
code has taken from the workbook. Col2 values
are the result of user input into a textbox.

Col1 values have been used to name sheets in a
new workbook

The Col2 values will be used to rename the
respective Col1 named sheet.

As I see it, before user leaves the form, I will
need to check Col2 as follows
:
a) that all entries are filled
b) that all values are valid
c) that all entries are unique
.....that's all I can think of.........?

User exits the form with 'Cancel' or 'Ok' buttons.

Where can I learn something of these techniques
please?

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01/09/2003



Dave Peterson[_3_]

Validating user input to a listbox
 
How about if the new names are legal?
How about if any of the new names are already in use?

Sheet1 becomes sheet2
sheet2 becomes sheet3
sheet3 becomes sheet1

As soon as you try to rename sheet1 to sheet2, trouble will occur.

(I guess the user shouldn't have to worry about that. You'll have to do
something in your code to make sure you rename them nicely.)

I think I'd rename each to a temporary unique name and then come back and rename
them nicely.

(I'm sure you'll find more things to check--right after you release version
1.0!)

Stuart wrote:

I've a 2 col multicolumn listbox. Col1 holds values
code has taken from the workbook. Col2 values
are the result of user input into a textbox.

Col1 values have been used to name sheets in a
new workbook

The Col2 values will be used to rename the
respective Col1 named sheet.

As I see it, before user leaves the form, I will
need to check Col2 as follows
:
a) that all entries are filled
b) that all values are valid
c) that all entries are unique
....that's all I can think of.........?

User exits the form with 'Cancel' or 'Ok' buttons.

Where can I learn something of these techniques
please?

Regards.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01/09/2003


--

Dave Peterson


Dick Kusleika[_2_]

Validating user input to a listbox
 
Stuart

:
a) that all entries are filled


You just cycle through all the entries and test the len of column two to be
greater than zero.

b) that all values are valid


Maybe try to insert the sheet into the existing workbook and rename it. Use
error checking to see if you get an error, and which error you get. If you
don't get an error, delete the "temporary" sheet.

c) that all entries are unique


You could put all the names in a collection with their name as the key
value, then compare Collection.Count to the number you should have.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com




Stuart[_5_]

Validating user input to a listbox
 
Many thanks to you both.

Regards.

"Dick Kusleika" wrote in message
...
Stuart

:
a) that all entries are filled


You just cycle through all the entries and test the len of column two to

be
greater than zero.

b) that all values are valid


Maybe try to insert the sheet into the existing workbook and rename it.

Use
error checking to see if you get an error, and which error you get. If

you
don't get an error, delete the "temporary" sheet.

c) that all entries are unique


You could put all the names in a collection with their name as the key
value, then compare Collection.Count to the number you should have.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com





---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 01/09/2003




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

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