Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default TextBox RowSource Question

Greetings,

I have two TextBoxes, TB1 and TB2, on a UserForm, UF1. I need to
enter a number in TB1 and on Exit have it find the name that is
associated with the entered number from a 2 column list in a named
range called List1, this list is sorted alphabetically.

The difficult part is I need to go in either direction. (ie put a
number in TB1 and TB2 shows the corresponding name OR put a name into
TB2 and the corresponding number shows up in TB1). The real problem
is that the names maybe duplicated with different numbers or some
numbers may have more then one name.

Anyone have an idea on where start?

Any help is appreciated.

TIA

-Minitman
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default TextBox RowSource Question

That isn't a programming problem - that is a business rule problem. sounds
like you need a combobox for each where, when a value is put in one
combobox, the other combobox fills with the matching possibilities.

You just need to loop through the matching column and do additem for the
matching cell in the other column. You will need to check in the click
event of each if there is already a value in the other combobox so you don't
get circular events.

--
Regards,
Tom Ogilvy



"Minitman" wrote in message
...
Greetings,

I have two TextBoxes, TB1 and TB2, on a UserForm, UF1. I need to
enter a number in TB1 and on Exit have it find the name that is
associated with the entered number from a 2 column list in a named
range called List1, this list is sorted alphabetically.

The difficult part is I need to go in either direction. (ie put a
number in TB1 and TB2 shows the corresponding name OR put a name into
TB2 and the corresponding number shows up in TB1). The real problem
is that the names maybe duplicated with different numbers or some
numbers may have more then one name.

Anyone have an idea on where start?

Any help is appreciated.

TIA

-Minitman



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default TextBox RowSource Question

Hey Tom,

Thanks for the reply.

What is a business rule?

I see the ComboBoxes for TextBoxes. But not sure how to get the
matching possibilities.

Could you be a bit more specific, please?

-Minitman

On Sun, 13 Feb 2005 19:47:04 -0500, "Tom Ogilvy"
wrote:

That isn't a programming problem - that is a business rule problem. sounds
like you need a combobox for each where, when a value is put in one
combobox, the other combobox fills with the matching possibilities.

You just need to loop through the matching column and do additem for the
matching cell in the other column. You will need to check in the click
event of each if there is already a value in the other combobox so you don't
get circular events.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default TextBox RowSource Question

Public bBlockEvent as Boolean

Private Sub Userform_Initialize()
Dim cell as Range
bBlockEvents = True
combobox1.Clear
combobox2.Clear
for each cell in Range("List").Columns(1).Cells
Combobox1.AddItem cell.Value
Combobox2.AddItem cell.Offset(0,1).Value
Next
bBlockEvents = False
End Sub

Private Sub Combobox1_Click()
if bBlockEvents = True then exit sub
If Combobox1.Value = "" then exit sub
if Trim(Combobox2.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(1).Cells
if lcase(cell.Value) = Combobox1.Value then
combobox2.AddItem cell.Offset(0,1).Value
end if
Next
End if
combobox2.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Private Sub Combobox2_Click()
if bBlockEvents = True then exit sub
If Combobox2.Value = "" then exit sub
If Trim(Combobox1.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(2).Cells
if lcase(cell.Value) = Combobox2.Value then
combobox1.AddItem cell.Offset(0,-1).Value
end if
Next
End if
combobox1.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Untested, but it should give you some ideas.

--
Regards,
Tom Ogilvy

"Minitman" wrote in message
...
Hey Tom,

Thanks for the reply.

What is a business rule?

I see the ComboBoxes for TextBoxes. But not sure how to get the
matching possibilities.

Could you be a bit more specific, please?

-Minitman

On Sun, 13 Feb 2005 19:47:04 -0500, "Tom Ogilvy"
wrote:

That isn't a programming problem - that is a business rule problem.

sounds
like you need a combobox for each where, when a value is put in one
combobox, the other combobox fills with the matching possibilities.

You just need to loop through the matching column and do additem for the
matching cell in the other column. You will need to check in the click
event of each if there is already a value in the other combobox so you

don't
get circular events.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default TextBox RowSource Question

Hey Tom,

There are a few items in your code that I am not familiar with. And
that is great! I will now attempt to understand how they works and
make use of them.
Thank you, I would never have even suspected that some of these
commands existed, let alone what they do.

As always, I am in your debt.

-Minitman

On Sun, 13 Feb 2005 20:45:52 -0500, "Tom Ogilvy"
wrote:

Public bBlockEvent as Boolean

Private Sub Userform_Initialize()
Dim cell as Range
bBlockEvents = True
combobox1.Clear
combobox2.Clear
for each cell in Range("List").Columns(1).Cells
Combobox1.AddItem cell.Value
Combobox2.AddItem cell.Offset(0,1).Value
Next
bBlockEvents = False
End Sub

Private Sub Combobox1_Click()
if bBlockEvents = True then exit sub
If Combobox1.Value = "" then exit sub
if Trim(Combobox2.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(1).Cells
if lcase(cell.Value) = Combobox1.Value then
combobox2.AddItem cell.Offset(0,1).Value
end if
Next
End if
combobox2.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Private Sub Combobox2_Click()
if bBlockEvents = True then exit sub
If Combobox2.Value = "" then exit sub
If Trim(Combobox1.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(2).Cells
if lcase(cell.Value) = Combobox2.Value then
combobox1.AddItem cell.Offset(0,-1).Value
end if
Next
End if
combobox1.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Untested, but it should give you some ideas.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default TextBox RowSource Question

Hey Tom,

I just went looking for bBlockEvent and could find no reference
anywhere. So I have to ask, what is it?

-Minitman



On Sun, 13 Feb 2005 20:45:52 -0500, "Tom Ogilvy"
wrote:

Public bBlockEvent as Boolean

Private Sub Userform_Initialize()
Dim cell as Range
bBlockEvents = True
combobox1.Clear
combobox2.Clear
for each cell in Range("List").Columns(1).Cells
Combobox1.AddItem cell.Value
Combobox2.AddItem cell.Offset(0,1).Value
Next
bBlockEvents = False
End Sub

Private Sub Combobox1_Click()
if bBlockEvents = True then exit sub
If Combobox1.Value = "" then exit sub
if Trim(Combobox2.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(1).Cells
if lcase(cell.Value) = Combobox1.Value then
combobox2.AddItem cell.Offset(0,1).Value
end if
Next
End if
combobox2.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Private Sub Combobox2_Click()
if bBlockEvents = True then exit sub
If Combobox2.Value = "" then exit sub
If Trim(Combobox1.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(2).Cells
if lcase(cell.Value) = Combobox2.Value then
combobox1.AddItem cell.Offset(0,-1).Value
end if
Next
End if
combobox1.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Untested, but it should give you some ideas.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default TextBox RowSource Question

Hey Tom,

Opps - I misinterpreted what I saw. I get the bBlockEvent!

I am having a bit of an identity problem! ComboBox1 is showing what
should be in ComboBox2 and visa-versa.

I tried playing with it, but nothing reacted as I thought it should!

Any suggestions?

-Minitman


On Sun, 13 Feb 2005 20:45:52 -0500, "Tom Ogilvy"
wrote:

Public bBlockEvent as Boolean

Private Sub Userform_Initialize()
Dim cell as Range
bBlockEvents = True
combobox1.Clear
combobox2.Clear
for each cell in Range("List").Columns(1).Cells
Combobox1.AddItem cell.Value
Combobox2.AddItem cell.Offset(0,1).Value
Next
bBlockEvents = False
End Sub

Private Sub Combobox1_Click()
if bBlockEvents = True then exit sub
If Combobox1.Value = "" then exit sub
if Trim(Combobox2.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(1).Cells
if lcase(cell.Value) = Combobox1.Value then
combobox2.AddItem cell.Offset(0,1).Value
end if
Next
End if
combobox2.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Private Sub Combobox2_Click()
if bBlockEvents = True then exit sub
If Combobox2.Value = "" then exit sub
If Trim(Combobox1.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(2).Cells
if lcase(cell.Value) = Combobox2.Value then
combobox1.AddItem cell.Offset(0,-1).Value
end if
Next
End if
combobox1.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Untested, but it should give you some ideas.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default TextBox RowSource Question

I believe I have made the changes to reverse what appears in which combobox.

Public bBlockEvent as Boolean

Private Sub Userform_Initialize()
Dim cell as Range
bBlockEvents = True
combobox1.Clear
combobox2.Clear
for each cell in Range("List").Columns(1).Cells
Combobox1.AddItem cell.Offet(0,1).Value
Combobox2.AddItem cell.Value
Next
bBlockEvents = False
End Sub

Private Sub Combobox1_Click()
if bBlockEvents = True then exit sub
If Combobox1.Value = "" then exit sub
if Trim(Combobox2.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(2).Cells
if lcase(cell.Value) = Combobox1.Value then
combobox2.AddItem cell.Offset(0,-1).Value
end if
Next
End if
combobox2.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Private Sub Combobox2_Click()
if bBlockEvents = True then exit sub
If Combobox2.Value = "" then exit sub
If Trim(Combobox1.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(1).Cells
if lcase(cell.Value) = Combobox2.Value then
combobox1.AddItem cell.Offset(0,1).Value
end if
Next
End if
combobox1.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

--
Regards,
Tom Ogilvy


"Minitman" wrote in message
...
Hey Tom,

Opps - I misinterpreted what I saw. I get the bBlockEvent!

I am having a bit of an identity problem! ComboBox1 is showing what
should be in ComboBox2 and visa-versa.

I tried playing with it, but nothing reacted as I thought it should!

Any suggestions?

-Minitman


On Sun, 13 Feb 2005 20:45:52 -0500, "Tom Ogilvy"
wrote:

Public bBlockEvent as Boolean

Private Sub Userform_Initialize()
Dim cell as Range
bBlockEvents = True
combobox1.Clear
combobox2.Clear
for each cell in Range("List").Columns(1).Cells
Combobox1.AddItem cell.Value
Combobox2.AddItem cell.Offset(0,1).Value
Next
bBlockEvents = False
End Sub

Private Sub Combobox1_Click()
if bBlockEvents = True then exit sub
If Combobox1.Value = "" then exit sub
if Trim(Combobox2.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(1).Cells
if lcase(cell.Value) = Combobox1.Value then
combobox2.AddItem cell.Offset(0,1).Value
end if
Next
End if
combobox2.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Private Sub Combobox2_Click()
if bBlockEvents = True then exit sub
If Combobox2.Value = "" then exit sub
If Trim(Combobox1.Value) = "" then
on Error goto ErrHandler
bBlockEvents = True
for each cell in Range("List").columns(2).Cells
if lcase(cell.Value) = Combobox2.Value then
combobox1.AddItem cell.Offset(0,-1).Value
end if
Next
End if
combobox1.ListIndex = 0
ErrHandler:
bBlockEvents = False
End Sub

Untested, but it should give you some ideas.




Reply
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
TextBox Question Jim Excel Discussion (Misc queries) 4 July 11th 08 10:41 PM
Textbox question? Greg B Excel Discussion (Misc queries) 2 June 2nd 05 03:56 PM
Textbox question Jorge Rodrigues[_2_] Excel Programming 4 November 13th 04 11:08 PM
textbox question dok112[_22_] Excel Programming 1 August 10th 04 07:54 AM
Textbox question 2 Rich Cooper Excel Programming 5 June 14th 04 08:51 PM


All times are GMT +1. The time now is 01:29 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"