I'm quite new to VB. Please come someone advise how I can move a row to another worksheet where a cell value equals the name of another worksheet.
Basically ... in my first worksheet (All Data), I have a range of data populated from an SQL script. In column A there are names of CS Reps that work for our company. Each CS Rep has their own worksheet.
What I need is for VB to check cell A2 (All Data) and move cell range A2:M2 to A2:M2 of the corresponding CS Rep worksheet. The Row from (All Data) should then be deleted.
This process needs to be on a loop until all rows from 'All Data' have moved to the corresponding CS Rep's worksheet. Any mismatches can move to another worksheet named 'Mismatch'. Matched rows should always copy to Row 2 of the corresponding worksheet moving existing data down a row.
I really hope that makes some sense !?!
Thanks SMORF
Sub MoveToCS()
Sheets("All Data").Select
Cells.Select
ActiveWorkbook.Worksheets("All Data").sort.SortFields.Clear
ActiveWorkbook.Worksheets("All Data").sort.SortFields.Add Key:=Range( _
"A2:A357"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("All Data").sort
.SetRange Range("A1:M357")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Cells.Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$M$1000").AutoFilter Field:=1, Criteria1:="ACHAL"
Range("A2:M1000").Select
Selection.Copy
Sheets("ACHAL").Select
Range("A2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("All Data").Select
Selection.EntireRow.Delete
ActiveSheet.Range("$A$1:$M$286").AutoFilter Field:=1
End Sub