Need VBA-code with a custom userform using the find method with both findnext and findprevious

  • Thread starter Thread starter Chris Warren
  • Start date Start date
C

Chris Warren

Hi:

I am attempting to develop a custom userform that incorporates both
findnext and findprevious. In addition, I want the results of the find
method to be displayed on the userform. Does anyone have sample code
for "find" that I could use for an example, or can you
point me in the right direction.

TIA,
Chris
 
Hi Chris,

here is some starter code

Option Explicit

Dim oPrev As Range
Dim oCell As Range

Private Sub cmdPrev_Click()
TextBox1.Text = oPrev.Text
End Sub

Private Sub cmdNext_Click()
Set oPrev = oCell
Set oCell = Worksheets("Menu").Cells.Find(what:="Bob", after:=oPrev)
If Not oCell Is Nothing Then
TextBox1.Text = oCell.Text
End If
End Sub

Private Sub UserForm_Activate()
Set oCell = Worksheets("Menu").Range("A1")
End Sub

Private Sub UserForm_Click()

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top