+ Reply to Thread
Results 1 to 5 of 5

Find Next Help - Please

  1. #1
    Registered User
    Join Date
    12-29-2003
    Posts
    8

    Find Next Help - Please

    The FindNext will not stay in Column A.
    Please help me, I have tried to enter the Range("A:A").Select
    in different lines, but nothing works.

    Sub LineSearch()
    Dim MyValue, MyFindNext
    Range("A:A").Select
    MyValue = InputBox("?")
    Cells.Find(What:=MyValue).Activate
    MyFindNext = vbYes
    Do Until MyFindNext <> vbYes
    MyFindNext = MsgBox("Next " & MyValue & "?", _
    vbYesNo, "Find Next")
    If MyFindNext = vbNo Then
    Exit Sub
    End If
    Cells.FindNext(After:=ActiveCell).Activate
    Loop
    Exit Sub

    End Sub

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    The code work good for me. it stays in column A for me

  3. #3
    Registered User
    Join Date
    12-29-2003
    Posts
    8
    I wondered what I done wrong?
    I tested my code on a test sheet by typing in column A
    cell A1 Dog, cell A2 Cat, Cell A3 Pig

    then I copied it over to column D
    cell D1 Dog, cell D2 Cat, Cell D3 Pig


    Then I typed in the Input box Cat and it went to A2, then to D2.

    It did not stay in column A?

    Thank you for your help, would you try the example please to see if yours does the same thing.

  4. #4
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    try this macro

    you need to use selection.find instead of cells.find , cells.find will search entire worksheet.


    Sub LineSearch()
    On Error GoTo b:
    Dim k As Variant
    k = 0


    Dim MyValue, MyFindNext
    Range("A:A").Select
    MyValue = InputBox("?")
    Selection.Find(What:=MyValue).Activate
    MyFindNext = vbYes
    k = 1
    Do Until MyFindNext <> vbYes
    MyFindNext = MsgBox("Next " & MyValue & "?", _
    vbYesNo, "Find Next")
    If MyFindNext = vbNo Then
    GoTo b:
    End If
    Selection.FindNext(After:=ActiveCell).Activate
    Loop
    b:
    If k = 1 Then

    Else
    MsgBox "no match found"
    End If
    End Sub

  5. #5
    Registered User
    Join Date
    12-29-2003
    Posts
    8
    It stayed in column A.
    Thank you very much for all of your help.
    I tried for several days to figure this out on my own without any sucess.
    I will save your information on the "selection.find" for any future attempts
    that I should try at VBA programing which I am not good at.
    Thank you again for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1