#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default find

I have a userform with two textboxes on it. I use it to find and return
values. How would i code this userform so as if i search the worksheet for
both values that it will return the values in that row? I need the first
textbox to search through column A and the second textbox to search through
column B. Both values must be found in the same row. I then need to return
the values from that row into another form. I have the code to return the
values.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default find

Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text = Columns(1))*(TextBox2.Text =
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find and return
values. How would i code this userform so as if i search the worksheet

for
both values that it will return the values in that row? I need the first
textbox to search through column A and the second textbox to search

through
column B. Both values must be found in the same row. I then need to

return
the values from that row into another form. I have the code to return the
values.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default find

I cant get this code to work for me.

"Bob Phillips" wrote:

Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text = Columns(1))*(TextBox2.Text =
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find and return
values. How would i code this userform so as if i search the worksheet

for
both values that it will return the values in that row? I need the first
textbox to search through column A and the second textbox to search

through
column B. Both values must be found in the same row. I then need to

return
the values from that row into another form. I have the code to return the
values.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default find

Sorry, you are right, that won't work. Here is an alternative (which should
work)

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text &
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text = Columns(1))*(TextBox2.Text

=
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find and return
values. How would i code this userform so as if i search the worksheet

for
both values that it will return the values in that row? I need the first
textbox to search through column A and the second textbox to search

through
column B. Both values must be found in the same row. I then need to

return
the values from that row into another form. I have the code to return

the
values.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default find

Bob this code still isnt working for me.

"Bob Phillips" wrote:

Sorry, you are right, that won't work. Here is an alternative (which should
work)

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text &
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text = Columns(1))*(TextBox2.Text

=
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find and return
values. How would i code this userform so as if i search the worksheet

for
both values that it will return the values in that row? I need the first
textbox to search through column A and the second textbox to search

through
column B. Both values must be found in the same row. I then need to

return
the values from that row into another form. I have the code to return

the
values.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default find

It may be wrap-around

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text & _
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet


if that doesn't work please supply details of what happens.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
Bob this code still isnt working for me.

"Bob Phillips" wrote:

Sorry, you are right, that won't work. Here is an alternative (which

should
work)

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text &
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text =

Columns(1))*(TextBox2.Text
=
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find and

return
values. How would i code this userform so as if i search the

worksheet
for
both values that it will return the values in that row? I need the

first
textbox to search through column A and the second textbox to search
through
column B. Both values must be found in the same row. I then need

to
return
the values from that row into another form. I have the code to

return
the
values.







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default find

Still doesnt seem to work. I added the code to a command button on the
userform. I added an else statement at the end giving a message box if it
didnt work and the message box pops up when i try to run the code.
"Bob Phillips" wrote:

It may be wrap-around

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text & _
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet


if that doesn't work please supply details of what happens.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
Bob this code still isnt working for me.

"Bob Phillips" wrote:

Sorry, you are right, that won't work. Here is an alternative (which

should
work)

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text &
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text =

Columns(1))*(TextBox2.Text
=
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find and

return
values. How would i code this userform so as if i search the

worksheet
for
both values that it will return the values in that row? I need the

first
textbox to search through column A and the second textbox to search
through
column B. Both values must be found in the same row. I then need

to
return
the values from that row into another form. I have the code to

return
the
values.








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default find

and it says?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
Still doesnt seem to work. I added the code to a command button on the
userform. I added an else statement at the end giving a message box if it
didnt work and the message box pops up when i try to run the code.
"Bob Phillips" wrote:

It may be wrap-around

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text & _
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet


if that doesn't work please supply details of what happens.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
Bob this code still isnt working for me.

"Bob Phillips" wrote:

Sorry, you are right, that won't work. Here is an alternative (which

should
work)

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text &
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text =

Columns(1))*(TextBox2.Text
=
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find

and
return
values. How would i code this userform so as if i search the

worksheet
for
both values that it will return the values in that row? I need

the
first
textbox to search through column A and the second textbox to

search
through
column B. Both values must be found in the same row. I then

need
to
return
the values from that row into another form. I have the code to

return
the
values.










  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default find

Private Sub CommandButton1_Click()
Dim c As range
Dim strF1 As String
Dim strF2 As String
Dim strAdd As String

If UserForm3.TextBox5.Text = "" Then
MsgBox "Please enter Part Number"
UserForm3.TextBox5.SetFocus
Exit Sub
End If

If UserForm3.TextBox6.Text = "" Then
MsgBox "Please enter Sequence Number"
UserForm3.TextBox6.SetFocus
Exit Sub
End If

strF1 = UserForm3.TextBox5.Text
strF2 = UserForm3.TextBox6.Text

'Assumes that Part numbers are in column B
With ActiveSheet.range("B:B")
Set c = .Find(strF1, LookIn:=xlValues, lookAt:=xlWhole)

If Not c Is Nothing Then
strAdd = c.Address
If c(1, 2).Value = strF2 Then GoTo Notify
Else:
MsgBox "Not Found"
Exit Sub
End If

Set c = .FindNext(c)
If Not c Is Nothing And c.Address < strAdd Then
Do
If c(1, 2).Value = strF2 Then GoTo Notify
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < strAdd
End If
End With

Notify:
MsgBox """" & strF1 & """ is next to """ & _
strF2 & """ in cells " & c.Resize(1, 2).Address

End Sub

Bob this code seems to do the search for me but instead of selecting the row
it gives a message box. Any ideas on how to select the row once it has been
found?

"Bob Phillips" wrote:

and it says?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
Still doesnt seem to work. I added the code to a command button on the
userform. I added an else statement at the end giving a message box if it
didnt work and the message box pops up when i try to run the code.
"Bob Phillips" wrote:

It may be wrap-around

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text & _
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet


if that doesn't work please supply details of what happens.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
Bob this code still isnt working for me.

"Bob Phillips" wrote:

Sorry, you are right, that won't work. Here is an alternative (which
should
work)

Dim iRow As Long

On Error Resume Next
iRow = ActiveSheet.Evaluate("Match(1, (""" & TextBox1.Text &
"""=A1:A1000)*(""" & _
TextBox2.Text & """=B1:B1000), 0)")
On Error GoTo 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Use something like this

On Error Resume Next
iRow = Application.Match(1,(TextBox1.Text =
Columns(1))*(TextBox2.Text
=
Columns(2)),0)
On Error Goto 0
If iRow 0 Then
'iRow now points to the matching row in the worksheet

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"enyaw" wrote in message
...
I have a userform with two textboxes on it. I use it to find

and
return
values. How would i code this userform so as if i search the
worksheet
for
both values that it will return the values in that row? I need

the
first
textbox to search through column A and the second textbox to

search
through
column B. Both values must be found in the same row. I then

need
to
return
the values from that row into another form. I have the code to
return
the
values.











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
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
find and delete duplicate entries in two columns or find and prin. campare 2 columns of numbers-find unique Excel Programming 1 November 24th 04 04:09 PM
find and delete text, find a 10-digit number and put it in a textbox Paul Excel Programming 3 November 16th 04 04:21 PM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM


All times are GMT +1. The time now is 11:55 PM.

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

About Us

"It's about Microsoft Excel"