Hi I'm trying to write a VBA macro that will search a sheet for a specific number, find all instances of that number and then copy each of the rows corresponding to that number into a sheet in a new workbook. As of now the macro can find the number and open the new workbook but it will not copy and paste the rows into the new workbook.
Sub stagehours()
Dim jobrequest As String
Dim jobsearch As String
Dim test As String
Dim i As Integer, j As Integer
i = 2
j = 2
jobrequest = InputBox("Please Enter a job number.") 'input job number'
test = Range("B:B").Find(What:=jobrequest)
If test = jobrequest Then
MsgBox "Job Found"
Set NewBook = Workbooks.Add
With NewBook
.SaveAs "jobreport.xls"
End With
NumRows = Range("A2", Range("A2").End(xlDown)).Rows.Count
For x = i To NumRows
If Cells(i, 2).Value = jobrequest Then
Rows("i:i").Select
Selection.Copy
Workbooks("jobreport.xls").Activate
ActiveSheet.Rows(j).Paste
j = j + 1
End If
Next
Bookmarks