I am attaching macro code. With this I have two issues.

1.When we run the macro it creates the results on same workbook.But I want to get the same results in a separate workbook.
2.When any of the string in input column has space(ex:performance testing),macro throws an error.
Can anyone help me out please. Macro code is as follows.

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim x As Range
Dim rng As Range
Dim last As Long
Dim p As Long
Dim q As Long

p = Worksheets.Count
For q = 1 To p
'change filter column in the following code
last = Sheets(q).Cells(Rows.Count, "B").End(xlUp).Row
Set rng = Sheets(q).Range("A1:E" & last)

Sheets(q).Range("B1:B" & last).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AA1"), Unique:=True

For Each x In Range([AA2], Cells(Rows.Count, "AA").End(xlUp))
With rng
.AutoFilter
.AutoFilter field:=2, Criteria1:=x.Value
.SpecialCells(xlCellTypeVisible).Copy

Sheets.Add(After:=Sheets(Sheets.Count)).Name = x.Value
ActiveSheet.Paste
End With
Next x

' Turn off filter
Sheets(q).AutoFilterMode = False

With Application
.CutCopyMode = False
.ScreenUpdating = True
End With
Next q

End Sub