+ Reply to Thread
Results 1 to 2 of 2

Find Text from textBox then past what is found on sheet1

  1. #1
    Mark Cover
    Guest

    Find Text from textBox then past what is found on sheet1

    I have a textbox and I want to be able to search for data in a workbook (that
    is entered in the textBox) and when data is found paste the entire row into
    sheet 1 of the workbook. Any help on this would be greatly appreciated.
    Thanks
    -mark
    Sample Code that does not work for me:
    Private Sub cmdFind_Click()
    Dim R As Range
    On Error Resume Next
    Dim Sheet As Worksheet
    With Worksheets("Sheet2").Range("")
    Set R = Range("activesheet").Find(What:=txtFind.Text, _
    LookAt:=xlWhole)
    If R Is Nothing Then
    MsgBox "Bummer"
    Else
    R.Copy Destination:=Worksheets("Sheet1").Range("E5")
    End If
    End With
    End Sub

  2. #2
    Tom Ogilvy
    Guest

    Re: Find Text from textBox then past what is found on sheet1

    Assuming you don't have any errors:

    code looks fine. so now you need to determine why it doesn't work. Turn on
    the macro recorder and do a successful Edit=>Find in the workbook with a
    string that would be entered in the textbox. Turn off the macro recorder
    and look at the code recorded. Make your find command have the same
    arguments as that one except for the What:= argument.

    Leave that as you have it.

    Remove the On Error Resume next line.

    Now run the code and see what happens.

    --
    Regards,
    Tom Ogilvy


    "Mark Cover" <[email protected]> wrote in message
    news:[email protected]...
    > I have a textbox and I want to be able to search for data in a workbook

    (that
    > is entered in the textBox) and when data is found paste the entire row

    into
    > sheet 1 of the workbook. Any help on this would be greatly appreciated.
    > Thanks
    > -mark
    > Sample Code that does not work for me:
    > Private Sub cmdFind_Click()
    > Dim R As Range
    > On Error Resume Next
    > Dim Sheet As Worksheet
    > With Worksheets("Sheet2").Range("")
    > Set R = Range("activesheet").Find(What:=txtFind.Text, _
    > LookAt:=xlWhole)
    > If R Is Nothing Then
    > MsgBox "Bummer"
    > Else
    > R.Copy Destination:=Worksheets("Sheet1").Range("E5")
    > End If
    > End With
    > End Sub




+ 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