Greetings,

I have code to cut-and-paste rows to another sheet based on the value in the first column matching the InputBox entry. It was adapted from code that searched for a word in the first column, and if I change what I have below to "Dim Number as String" and change the InputBox data type to 2, it works perfectly for words. Unfortunately, I need it to look for a number in the first column, but it doesn't seem to see the numbers (either in number, general, or text format). I need it to do two things:

1) Copy and paste the rows beginning with the number (the number that's in column A of Sheet1) entered in the InputBox onto Sheet2, and only take the rows beginning with that exact number (in other words, only the row beginning with, say, 2 - not 22, 12, 122, etc.).

2) Delete whatever was in Sheet2 from the previous query before pasting the new set of rows.

Thank you in advance for your assistance; my code is as follows:

Sub CopyPaste042013()
Dim Number As Integer
Number = Application.InputBox("Enter the number you are looking for below", "Enter your number", , , , , , 1)
  
Application.ScreenUpdating = False
Dim xRow&, NextRow&, LastRow&
NextRow = 2
LastRow = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByRows, 

SearchDirection:=xlPrevious).Row
For xRow = 1 To LastRow
If WorksheetFunction.CountIf(Rows(xRow), "*" & Number & "*") > 0 Then
Rows(xRow).Copy Sheets("Sheet2").Rows(NextRow)
NextRow = NextRow + 1
End If
Next xRow
Application.ScreenUpdating = True
 
MsgBox "Macro is complete, " & NextRow - 2 & " rows containing" & vbCrLf & _
"''" & Number & "''" & " were copied to Sheet2.", 64, "Done"
End Sub
Nikolette