LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default UserForm Questtion

Greetings,
I use the following code to get input from the user. ListBox1 provides a
list of "Areas" (NAreaName) in my project. ListBox2 provides a list of
potential new "Areas" to add. TextBox1 provides a way for the user to enter
a new "Area" by typing its name. The length is checked and also a check is
done to see if the newly entered name is already in the project. This all
works fine.

Here is the question; One of my users happened to click on ListBox2 and then
entered a new "Area" in TextBox1 which is really what was desired, however,
when the macro was finished, the "Area" selected in ListBox2 was added to
the project vs the new name. How would you change this code to deal with
this mis entry issue?

Hopefully I have explained the issue so it can be understood.

Thanks in advance for your help!

Ray

Do
UserForm2.Show
NAreaName = UserForm2.TextBox1.Value

If Not UserForm2.ListBox2.ListIndex = -1 Then ' selecting typical
NAreaName = UserForm2.ListBox2.Value
End If
If Not bResponse Then
MsgBox "Cancel Selected"
End
End If
If NAreaName = "" Then
blnExit = False
ElseIf Len(NAreaName) 22 Then ' check if name fits length
MsgBox "Name is more than 22 characters! Try Again"
blnExit = False
ElseIf Application.CountIf(Range("AreaNames"), _
NAreaName) 0 Then ' see if name has been used
MsgBox "Name has already been used."
blnExit = False
Else
blnExit = True
End If
Loop While blnExit = False


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
userform carwincarber New Users to Excel 0 October 23rd 05 06:59 PM
Linking userform to userform in Excel 2003 missmelis01 Excel Programming 2 August 27th 04 08:07 PM
Userform Todd Huttenstine Excel Programming 3 July 9th 04 11:07 PM
userform Aashi Excel Programming 2 April 25th 04 06:39 PM
Userform inside another userform Ryan Excel Programming 0 April 23rd 04 08:01 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"