Hi All,
I run a query that has 10 accounts and I'm trying to write a program that will take the original data dump and create a new worksheet, rename it for a given account # and delete all accounts except a specified one and repeat until I have a worksheet for each account and still have the results from the original query. The approach I'm taking seems to work when I started writing it for just one account but I run into problems when I add the block of code for the other account. It seems to run super quick for one but when the coding for the other accounts is added the procedure runs and runs and I have to break the script. Even when I comment all the other accounts and try to run the first account I run into different errors. Can anyone see a problem or have a recommendation for a different approach?
Application.ScreenUpdating = False
ActiveSheet.Name = "ALL Data"
'Application.Run "PERSONAL.XLSB!LandscaptPgSetup"
ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = "10-111595"
Cells(Rows.Count, 9).End(xlUp).Select
Do Until ActiveCell.Row = 1
If ActiveCell <> 111595 Or ActiveCell.Offset(0, -1) <> 10 Then ActiveCell.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
Loop
Worksheets("All Data").Activate
'ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'ActiveSheet.Name = "10-111599"
'
'
'Cells(Rows.Count, 9).End(xlUp).Select
'
'Do Until ActiveCell.Row = 1
'
'If ActiveCell <> 111599 Or ActiveCell.Offset(0, -1) <> 10 Then ActiveCell.EntireRow.Delete
'ActiveCell.Offset(-1, 0).Select
'Loop
'
'Worksheets("All Data").Activate
'
'
'ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'ActiveSheet.Name = "10-111520"
'
'
'Cells(Rows.Count, 9).End(xlUp).Select
'
'Do Until ActiveCell.Row = 1
'
'If ActiveCell <> 111520 Or ActiveCell.Offset(0, -1) <> 10 Then ActiveCell.EntireRow.Delete
'ActiveCell.Offset(-1, 0).Select
'Loop
'
'Worksheets("All Data").Activate
'
'ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'ActiveSheet.Name = "10-111540"
'
'
'Cells(Rows.Count, 9).End(xlUp).Select
'
'Do Until ActiveCell.Row = 1
'
'If ActiveCell <> 111540 Or ActiveCell.Offset(0, -1) <> 10 Then ActiveCell.EntireRow.Delete
'ActiveCell.Offset(-1, 0).Select
'Loop
'
'Worksheets("All Data").Activate
'
'
'ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'ActiveSheet.Name = "35-111595"
'
'
'Cells(Rows.Count, 9).End(xlUp).Select
'
'Do Until ActiveCell.Row = 1
'
'If ActiveCell <> 111595 Or ActiveCell.Offset(0, -1) <> 35 Then ActiveCell.EntireRow.Delete
'ActiveCell.Offset(-1, 0).Select
'Loop
'
'Worksheets("All Data").Activate
'
'
'ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'ActiveSheet.Name = "55-111595"
'
'
'Cells(Rows.Count, 9).End(xlUp).Select
'
'Do Until ActiveCell.Row = 1
'
'If ActiveCell <> 111595 Or ActiveCell.Offset(0, -1) <> 55 Then ActiveCell.EntireRow.Delete
'ActiveCell.Offset(-1, 0).Select
'Loop
'
'Worksheets("All Data").Activate
'
'
'ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'ActiveSheet.Name = "BL-111510"
'
'
'Cells(Rows.Count, 9).End(xlUp).Select
'
'Do Until ActiveCell.Row = 1
'
'If ActiveCell <> 111510 Or ActiveCell.Offset(0, -1) <> BL Then ActiveCell.EntireRow.Delete
'ActiveCell.Offset(-1, 0).Select
'Loop
'
'Worksheets("All Data").Activate
'
'
'ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
'ActiveSheet.Name = "10-112710"
'
'
'Cells(Rows.Count, 9).End(xlUp).Select
'
'Do Until ActiveCell.Row = 1
'
'If ActiveCell <> 112710 Or ActiveCell.Offset(0, -1) <> 10 Then ActiveCell.EntireRow.Delete
'ActiveCell.Offset(-1, 0).Select
'Loop
'
'Worksheets("All Data").Activate
Application.ScreenUpdating = True
End Sub
Bookmarks