View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
BernzG[_13_] BernzG[_13_] is offline
external usenet poster
 
Posts: 1
Default Using Find & FindNext in a form


Hi,

Can someone please help me here - trying to get Find and FindNext to
work within to populate data within a form to enable it to be edited.


Private Sub CommandButton1_Click()

Dim Loc As String

Loc = Format(TextBox1.Value, "####")

Sheets("Sheet1").Select
Cells.Find(What:=Loc, After:=ActiveCell, LookIn:=xlValues, LookAt:=
_
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate


With Worksheets("Sheet1")
Set C = .Range("A:A").Find(Loc, LookIn:=xlValues)

If Not C Is Nothing And .Cells(C.Row, 1) < Loc Then firstAddress =
C.Address
Do
Set C = .Range("A:A").FindNext(C)
Loop While Not C Is Nothing And .Cells(C.Row, 1) < Loc And
C.Address < firstAddress

TextBox2 = .Cells(C.Row, 2)
TextBox3 = .Cells(C.Row, 3)
End With

End Sub

Cheers,
Bernz


--
BernzG
------------------------------------------------------------------------
BernzG's Profile: http://www.excelforum.com/member.php...o&userid=22949
View this thread: http://www.excelforum.com/showthread...hreadid=395711