Hi,
It has been 8 years since I have dabbled in Excel macros. So I need help! I am using the Excel for Auditors 2007 Edition so maybe that is my issue.
I have a report that list Reps in column G. I need to loop through all rows on the sheet, create a worksheet based on that value and move the rows from that sheet to the newly created sheet.
It works but nothing I do prevents the code from grabbing other reps. I have been staring at this for days and I admit I need assistance.
Prior to this, I create the sheet for the rep and that works fine. But I need for this loop to STOP when it gets to the next Rep and then execute the prior code again. and so on and so on. I have tried everything with my limited knowledge and ended up here. Don't laugh please hahahahaha! I have no clue if nesting a For loop into a While loop is even a thang! Any help would be greatly appreciated!
Rep and Val both point to the value in cell G. That was my workaround to stop the loop once it reached another rep but it is not working.
While Rep = Val
For ThisRow = 2 To FinalRow Step 1
Rep = Cells(ThisRow, 7)
NextRow = Worksheets(Val).Cells(1048576, 1).End(xlUp).Row
Cells(ThisRow, 1).Resize(1, 13).Copy Destination:=Worksheets(Val).Cells(NextRow + 1, 1)
Next ThisRow
Wend
It has been 8 years since I have dabbled in Excel macros. So I need help! I am using the Excel for Auditors 2007 Edition so maybe that is my issue.
I have a report that list Reps in column G. I need to loop through all rows on the sheet, create a worksheet based on that value and move the rows from that sheet to the newly created sheet.
It works but nothing I do prevents the code from grabbing other reps. I have been staring at this for days and I admit I need assistance.
Prior to this, I create the sheet for the rep and that works fine. But I need for this loop to STOP when it gets to the next Rep and then execute the prior code again. and so on and so on. I have tried everything with my limited knowledge and ended up here. Don't laugh please hahahahaha! I have no clue if nesting a For loop into a While loop is even a thang! Any help would be greatly appreciated!
Rep and Val both point to the value in cell G. That was my workaround to stop the loop once it reached another rep but it is not working.
While Rep = Val
For ThisRow = 2 To FinalRow Step 1
Rep = Cells(ThisRow, 7)
NextRow = Worksheets(Val).Cells(1048576, 1).End(xlUp).Row
Cells(ThisRow, 1).Resize(1, 13).Copy Destination:=Worksheets(Val).Cells(NextRow + 1, 1)
Next ThisRow
Wend