When I Ran this below code All rows values split in to different sheet, I didn't understand where i done mistake. please modify this and provide correct solution.
Thank for advance.
Private Sub CommandButton1_Click()
Dim lr As Long
Dim Ws As Worksheet
Dim vcol, i As Integer
Dim icol As Long
Dim myarr As Variant
Dim title As String
Dim titlerow As Integer
vcol = 1
Set Ws = Sheets("Sheet1")
lr = Ws.Cells(Ws.Rows.Count, vcol).End(xlUp).Row
title = "A1:D1"
titlerow = Ws.Range(title).Cells(1).Row
icol = Ws.Columns.Count
Ws.Cells(1, icol) = "Unique"
For i = 2 To lr
On Error Resume Next
If Ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(Ws.Cells(i, vcol), Ws.Columns(icol), 0) = 0 Then
Ws.Cells(Ws.Rows.Count, icol).End(xlUp).Offset(1) = Ws.Cells(i, vcol)
End If
Next
myarr = Application.WorksheetFunction.Transpose(Ws.Columns(icol).SpecialCells(xlCellTypeConstants))
Ws.Columns(icol).Clear
For i = 2 To UBound(myarr)
Ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
Else
Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
End If
Ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
Sheets(myarr(i) & "").Columns.AutoFit
Next
Ws.AutoFilterMode = False
Ws.Activate
End Sub