Loss1003
04-29-2016, 07:40 AM
I found the following code to Copy Data From One Sheet to Another with Input Box however the code runs extremely slow because it bounces back an forth the two sheets searching thru every row. Please help me to speed up the code.
Sub copy_paste_data_from_one_sheet_to_another()
'Let's start at row 2. Row 1 has headers
Sheet4.Activate
x = 2
Dim myName As String
myName = Application.InputBox("Enter a name")
'Worksheets("Sheet1").Activate
'Start the loop
Do While Cells(x, 27) <> ""
'Look for name
If Cells(x, 27) = myName Then
'copy the row if it contains 'myName'
Worksheets("Payment Upload").Rows(x).Copy
'Go to sheet2. Activate it. We want the data here
Worksheets("Sheet3").Activate
'Find the first empty row in sheet2
erow = Sheet10.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'Paste the data here
Application.DisplayAlerts = False
ActiveSheet.Paste Destination:=Worksheets("Sheet3").Rows(erow)
Application.DisplayAlerts = True
End If
'go to sheet1 again and actvate it
Worksheets("Payment Upload").Activate
'Loop through the other rows with data
x = x + 1
Loop
End Sub
Sub copy_paste_data_from_one_sheet_to_another()
'Let's start at row 2. Row 1 has headers
Sheet4.Activate
x = 2
Dim myName As String
myName = Application.InputBox("Enter a name")
'Worksheets("Sheet1").Activate
'Start the loop
Do While Cells(x, 27) <> ""
'Look for name
If Cells(x, 27) = myName Then
'copy the row if it contains 'myName'
Worksheets("Payment Upload").Rows(x).Copy
'Go to sheet2. Activate it. We want the data here
Worksheets("Sheet3").Activate
'Find the first empty row in sheet2
erow = Sheet10.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'Paste the data here
Application.DisplayAlerts = False
ActiveSheet.Paste Destination:=Worksheets("Sheet3").Rows(erow)
Application.DisplayAlerts = True
End If
'go to sheet1 again and actvate it
Worksheets("Payment Upload").Activate
'Loop through the other rows with data
x = x + 1
Loop
End Sub