Hello i have a work sheet with 10s of thousands of row entries and i am looking to search for a specific value in column A and based on that value copy the whole row to a specific worksheet.
I have simplified my example - here i have a worksheet with three variables in column A "Treadmill", "Bike" and "Rower" and based on the entry in column A i want to move the whole row to a tab called "Treadmill", "Bike" or "Rower". This does work but when i extend my data to thousands of rows excels hangs and takes a very long time to run.
Are there any quicker methods (note the number of splitting option requirements will rise to around 40/50 tabs)
Sub split_Excercise()
Dim totalentries As Integer
Dim treadmillentries As Integer
Dim bikeentries As Integer
Dim rowerentries As Integer
Dim i As Integer
Sheets(Array("Treadmill", "Bike", "Rower")).Select
Range("A2:e1048576").Select
Selection.ClearContents
Sheets("All Excercise").Select
totalentries = Worksheets("All Excercise").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To totalentries
If Worksheets("All Excercise").Cells(i, 1).Value = "Treadmill" Then
Worksheets("All Excercise").Rows(i).Copy
Worksheets("Treadmill").Activate
treadmillentries = Worksheets("Treadmill").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Treadmill").Cells(treadmillentries + 1, 1).Select
ActiveSheet.Paste
Cells(1, 1).Select
ElseIf Worksheets("All Excercise").Cells(i, 1).Value = "Bike" Then
Worksheets("All Excercise").Rows(i).Copy
Worksheets("bike").Activate
bikeentries = Worksheets("bike").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("bike").Cells(bikeentries + 1, 1).Select
ActiveSheet.Paste
Cells(1, 1).Select
ElseIf Worksheets("All Excercise").Cells(i, 1).Value = "Rower" Then
Worksheets("All Excercise").Rows(i).Copy
Worksheets("Rower").Activate
rowerentries = Worksheets("rower").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("rower").Cells(rowerentries + 1, 1).Select
ActiveSheet.Paste
Cells(1, 1).Select
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("All Excercise").Activate
Cells(1, 1).Select
End Sub
I have simplified my example - here i have a worksheet with three variables in column A "Treadmill", "Bike" and "Rower" and based on the entry in column A i want to move the whole row to a tab called "Treadmill", "Bike" or "Rower". This does work but when i extend my data to thousands of rows excels hangs and takes a very long time to run.
Are there any quicker methods (note the number of splitting option requirements will rise to around 40/50 tabs)
Sub split_Excercise()
Dim totalentries As Integer
Dim treadmillentries As Integer
Dim bikeentries As Integer
Dim rowerentries As Integer
Dim i As Integer
Sheets(Array("Treadmill", "Bike", "Rower")).Select
Range("A2:e1048576").Select
Selection.ClearContents
Sheets("All Excercise").Select
totalentries = Worksheets("All Excercise").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To totalentries
If Worksheets("All Excercise").Cells(i, 1).Value = "Treadmill" Then
Worksheets("All Excercise").Rows(i).Copy
Worksheets("Treadmill").Activate
treadmillentries = Worksheets("Treadmill").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Treadmill").Cells(treadmillentries + 1, 1).Select
ActiveSheet.Paste
Cells(1, 1).Select
ElseIf Worksheets("All Excercise").Cells(i, 1).Value = "Bike" Then
Worksheets("All Excercise").Rows(i).Copy
Worksheets("bike").Activate
bikeentries = Worksheets("bike").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("bike").Cells(bikeentries + 1, 1).Select
ActiveSheet.Paste
Cells(1, 1).Select
ElseIf Worksheets("All Excercise").Cells(i, 1).Value = "Rower" Then
Worksheets("All Excercise").Rows(i).Copy
Worksheets("Rower").Activate
rowerentries = Worksheets("rower").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("rower").Cells(rowerentries + 1, 1).Select
ActiveSheet.Paste
Cells(1, 1).Select
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("All Excercise").Activate
Cells(1, 1).Select
End Sub