Update

  • Thread starter Thread starter Robert Couchman
  • Start date Start date
R

Robert Couchman

Hello,

can anyone help, i am looking for a piece of code that can
be used as a update text box.

i have 3 text boxes and a list box, what i want is so
that if a value is typed into one of the boxes it will
list the related information in the list box,

i.e. if a person types 'Rob' in the middle text box (name
box)
then the list box will produce a list where all the values
in the name column begin with 'Rob', and then using the
offset command (unless others are better) it will display
all the relevant information.

i could then manipulate the code so that if a value is
typed into another field that is incorrect or does not
appear in that column then the results would disapear, or
if the correct data is entered it will narrow the
selection more.

Thank you for all help,

Robert Couchman
 
Listbox1.Clear
With worksheets("Data")
set rng = .Range(.Cells(2,5),.Cells(2,5).End(xldown))
End with
for each cell in rng
if instr(1,cell,Textbox2.Text,vbTextCompare) then
listbox1.AddItem cell.Value
end if
Next
 
Thank you Tom,

but under what Private sub should i call this feature?
i usualy try _afterupdate()
also where would this usualy be best placed?
i would think textbox2_afterupdate looking at the
procedure!

Thank you,

Robert Couchman
 
That sounds good to me.

--
Regards,
Tom Ogilvy

Robert Couchman said:
Thank you Tom,

but under what Private sub should i call this feature?
i usualy try _afterupdate()
also where would this usualy be best placed?
i would think textbox2_afterupdate looking at the
procedure!

Thank you,

Robert Couchman
 
Any idea of how to get more than 1 text box to edit the
data in the list?

I.e. you type "Rob" in textbox1 and "Couch" in textbox2
and the list will produce th results "Robert Couchman"?

i can get the list to display the full data in more than 1
cell,
e.g. i type "rob" and it will list all cells with "rob" in
and also the following cells "Robert Couchman"

Thank you,

Robert Couchman
 
Assume Robert Couchman is all in one cell:

Listbox1.Clear
With worksheets("Data")
set rng = .Range(.Cells(2,5),.Cells(2,5).End(xldown))
End with
for each cell in rng
if instr(1,cell,Textbox1.Text,vbTextCompare) and _
instr(1,cell,Textbox2.Text,vbTextCompare) then
listbox1.AddItem cell.Value
end if
Next
 
Back
Top