View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Searching data within sheets

My apologies...I know nothing about userforms...sorry.
--
Gary''s Student - gsnu200767


"Barbara" wrote:

Hi Gary,
Thaks a lot. It worked just fine.
But one more little thing! How can I present my record in a Form.
I tried this: (had to define the variable, hope this is correct.)

Sub TakeMeThere()
Dim v
Dim w
Dim n
Dim i

v = ActiveCell.Value
Set w = ActiveSheet
Sheets("Contactos").Activate
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To n
If Cells(i, "B").Value = v Then
Cells(i, "B").Select
ActiveSheet.ShowDataForm *********** (my new Line)
Exit Sub
End If
Next
w.Activate
MsgBox (v & " não existe !")
End Sub

The thing is that is shows the Form for the first record and not the one I
asked him to find! How can I fix this?
Hope to hear from you soon.
Thanks,
Barbara

"Gary''s Student" wrote:

Use:

Sub takemethere()
v = ActiveCell.Value
Set w = ActiveSheet
Sheets("details").Activate
n = Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To n
If Cells(i, "C").Value = v Then
Cells(i, "C").Select
Exit Sub
End If
Next
w.Activate
MsgBox (v & " not found")
End Sub


Click on the cell with the client number and run the macro above. The macro
goes to a sheet named "details" and looks in column C for that client number.
If the client number is found, that cell is selected. If the client number
is not found, a warning is issued.


You must substitute the proper tab name for "details" and the proper column
for column C.

--
Gary''s Student - gsnu200767