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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top