find and paste

G

Guest

This is the code im using. The part from Founcell.Copy does not seem to be
working.
Can anyone help?

Private Sub CommandButton1_Click()
Dim wks As Worksheet
Dim FoundCell As Range

Set wks = Worksheets("Sheet1")
If Me.TextBox1.Value = "" Then
Beep
MsgBox "Please enter HRI"
Exit Sub
End If

With wks
With .Range("A:A")

Set FoundCell = .Cells.Find(what:=Me.TextBox1.Value, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
Lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)

FoundCell.Copy

Sheets("Sheet2").Select

Range("A2").Select

ActiveSheet.Paste

UserForm1.Hide

Sheets("Sheet2").Select
End With
End With

If FoundCell Is Nothing Then
UserForm1.Hide
UserForm2.Show


Else
MsgBox "Found HRI: " & FoundCell.Value
End If


End Sub
 
Z

Zone

enyaw,
I copied your code to a regular module, removed all references to
the userforms, and told it to find a specific string. Worked fine.
Maybe that gives you a clue.
Zone
 

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

Top