View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Steved Steved is offline
external usenet poster
 
Posts: 519
Default search 2 Columns Please

Hello from Steved

If I type 041,7.50 I am getting the below error

Object dosen't support this property or method.

Please what is Required to the below macro to correct this. Thankyou.

"Tom Ogilvy" wrote:

Sub FindPart()
Dim res as String, saddr As String
Dim RgToSearch As Range, RgFound As Range
Dim secondValue As String
Set RgToSearch = ActiveSheet.Range("C:C")

res = Application.InputBox("Type School Number", _
"Find School", , , , , , 2)
If res = "False" Then Exit Sub 'exit if Cancel is clicked
res = Trim(UCase(res))
If res = "" Then Exit Sub 'exit if no entry and OK is clicked
If instr(1,res,",",vbtextcompare) = 0 then
msgbox "Invalid entry"
exit sub
end if
v = Application.Split(res,",")
res = trim(v(lbound(v)))
secondValue = trim(v(ubound(v)))
Set RgFound = RgToSearch.Find(what:=res, _
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
If RgFound Is Nothing Then
MsgBox "School " & res & " not found."
Exit Sub
Else
saddr = RgFound.Address
Do
If RgFound.Offset(0, 1).Text = secondValue Then
Application.Goto Reference:= _
RgFound.Offset(0, -1).Address(True, True, xlR1C1)
Exit Do
End If
Set RgFound = RgToSearch.FindNext(RgFound)
Loop While RgFound.Address < saddr

End If
If RgFound.Offset(0, 1).Text < secondValue Then
MsgBox " School found, but not 8.00"
End If
End Sub

--
Regards,
Tom Ogilvy

"Steved" wrote in message
...
Hello Tom

This is what I need

I type in say 001,8.00 it will find 001,8.00.
if I type in 041,7.50 or 034.3.25 I would like it to find those also.

What I am explaining is that i've many entries, can your macro which you
have kindly done for me be futher programmed, to be able to do multiple.

Thankyou .



"Tom Ogilvy" wrote:

This is pretty much what I posted, but I made a variable to hold the

3.30 or
8.00 as a string. It found 8 formatted as 000 (stored as a number) and

the
string "008"

Sub FindPart()
Dim res, saddr As String
Dim RgToSearch As Range, RgFound As Range
Dim secondValue As String
Set RgToSearch = ActiveSheet.Range("C:C")

secondValue = "8.00"
res = Application.InputBox("Type School Number", _
"Find School", , , , , , 2)
If res = "False" Then Exit Sub 'exit if Cancel is clicked
res = Trim(UCase(res))
If res = "" Then Exit Sub 'exit if no entry and OK is

clicked

Set RgFound = RgToSearch.Find(what:=res, _
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
If RgFound Is Nothing Then
MsgBox "School " & res & " not found."
Exit Sub
Else
saddr = RgFound.Address
Do
If RgFound.Offset(0, 1).Text = secondValue Then
Application.Goto Reference:= _
RgFound.Offset(0, -1).Address(True, True, xlR1C1)
Exit Do
End If
Set RgFound = RgToSearch.FindNext(RgFound)
Loop While RgFound.Address < saddr

End If
If RgFound.Offset(0, 1).Text < secondValue Then
MsgBox " School found, but not 8.00"
End If
End Sub

--
Regards,
Tom Ogilvy


"Steved" wrote in message
...
Hello from Steved

If I type in 001,8.00
The message box saing School 001, 8.00 not found but I can see it.

001 is in Col C and 8.00 is in Col D What is required please to

correct
the
below macro Thankyou.

Sub FindPart()
Dim res, saddr As String
Dim RgToSearch As Range, RgFound As Range

Set RgToSearch = ActiveSheet.Range("C:C")

res = Application.InputBox("Type School Number", _
"Find School", , , , , , 2)
If res = "False" Then Exit Sub 'exit if Cancel is clicked
res = Trim(UCase(res))
If res = "" Then Exit Sub 'exit if no entry and OK is

clicked

Set RgFound = RgToSearch.Find(what:=res, _
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
If RgFound Is Nothing Then
MsgBox "School " & res & " not found."
Exit Sub
Else
saddr = RgFound.Address
Do
If RgFound.Offset(0, 1).Text = "3.30" Then
Application.Goto

Reference:=RgFound.Offset(0, -1).Address(True,
True, xlR1C1)
Exit Do
Set RgFound = RgToSearch.FindNext(RgFound)

End If
If RgFound.Offst(0, 1).Text < "3.30" Then
MsgBox "School found, but not 3.30"

End If
Loop While RgFound < saddr
End If
End Sub





"Steved" wrote:

Hello from Steved

It's first day back at work.

All I need to dois hit the enter key and it will look for the next

and
so on.

Thankyou.

"Steved" wrote:

Hello from Steved

The below will find what I require in Column C ie 002
What do I need to do please for it to search Col C for 002 and Col

D
for 3.30
Both are on the same row.

Thankyou.

Sub FindPart()
Dim res
Dim RgToSearch As Range, RgFound As Range

Set RgToSearch = ActiveSheet.Range("C:C")

res = Application.InputBox("Type School Number", "Find

School", ,
, , ,
, 2)
If res = "False" Then Exit Sub 'exit if Cancel is clicked
res = Trim(UCase(res))
If res = "" Then Exit Sub 'exit if no entry and OK is
clicked

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues,
lookat:=xlWhole, MatchCase:=False)
If RgFound Is Nothing Then
MsgBox "School " & res & " not found."
Else
Application.Goto Reference:=RgFound.Offset(0, -1).Address(True,
True,
xlR1C1)
End If

End Sub