Gentlemen
I am new to VBA and I have created some code that copys rows from one worksheet and pastes them to another. The code is working great it is just really slow. I was wondering if anyone could look at my code and make recommendations on how to speed it up.
Thank You for any help you can provide!
Sub CopyTypeI()
Dim Val As Integer
'Clears the sheeting
Sheets("TypeI").UsedRange.Clear
Val = Sheets("Database").UsedRange.Rows.Count
'Finds all ASTM Type I White Traffic Signs in the Database worksheet
For i = 1 To Val Step 1
If Sheets("Database").UsedRange.Cells(i, 17).Value = "Type I" And Sheets("Database").UsedRange.Cells(i, 8).Value = "White" Then
Sheets("Database").Rows(i).EntireRow.Copy Destination:=Sheets("TypeI").Range("B200000").End(xlUp).Offset(1, -1)
End If
Next
'Finds all ASTM Type I Green Traffic Signs in Database worksheet copys them and paste them into a column in the TypeI worksheet
For i = 1 To Val Step 1
If Sheets("Database").UsedRange.Cells(i, 17).Value = "Type I" And Sheets("Database").UsedRange.Cells(i, 8).Value = "Green" Then
Worksheets("Database").Rows(i).Range("A1:AX1").Copy Destination:=Worksheets("TypeI").Range("BB200000").End(xlUp).Offset(1, -1)
End If
Next
'Finds all ASTM Type I Yellow Traffic Signs in Database worksheet copys them and paste them into a column in the TypeI worksheet
For i = 1 To Val Step 1
If Sheets("Database").UsedRange.Cells(i, 17).Value = "Type I" And Sheets("Database").UsedRange.Cells(i, 8).Value = "Yellow" Then
Worksheets("Database").Rows(i).Range("A1:AX1").Copy Destination:=Worksheets("TypeI").Range("DC200000").End(xlUp).Offset(1, -1)
End If
Next
End Sub
Bookmarks