I am trying to copy rows of data into new sheets. I have a list with agent names and amount of total sales.
Have read through must be at least 15 different threads with this issue yet everything I've tried just results in errors.
I'm just trying to copy the row one sheet and copy it to the next. Weird thing is that it actually worked earlier today!!
Hopefully it's just something simple that I'm missing.
Set objWorksheet = ThisWorkbook.Worksheets("Control")
Set rng = objWorksheet.Range("A1:A" & objWorksheet.Cells(Rows.Count, "A").End(xlUp).Row)
Sheets("Control").Select
Range("A2").Select
Do Until IsEmpty(ActiveCell)
strAgent = ActiveCell.Value
For Each rngCell In rng.Cells
objWorksheet.Select
If rngCell.Value = strAgent Then
rngCell.EntireRow.Copy
Set objNewSheet = Worksheets(strAgent)
objNewSheet.Select
objNewSheet.Range("A2:G1000").ClearContents
Set rngNextRow = objNewSheet.Range("A1:A" & objNewSheet.Cells(Rows.Count, "A").End(xlUp).Row)
Range("A" & rngNextRow.Rows.Count + 1).Select
objNewSheet.Paste
End If
Next rngCell
ActiveCell.Offset(1, 0).Select
Loop
Thanks in advance!
EDIT:
The code seemingly worked when I removed the clear contents part. But now it seems to copy the same data over and over (7 times) before trying to move on to the next agents data and sheet.