Hello! I'm trying to automate a tedious process using the base code below.
This works fine to move all of the rows containing BIO, but each college has multiple courses. I'd like to be able to find a way to automate *all* of the relevant course codes to move into the ArtsnSci sheet. Is there a way to make it transfer all rows containing, for example, BIO, HIST, PHYS, or CHEM into the ArtsnSci sheet without replacing the "BIO" in the code with "HIST" and re-running each time?
VBA Code:
Sub ArtsnSci()
'Updated by Kutools for Excel 2017/8/28
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("AllCourses").UsedRange.Rows.Count
J = Worksheets("ArtsnSci").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("ArtsnSci").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("AllCourses").Range("C2:C" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "BIO" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("ArtsnSci").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "Done" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
This works fine to move all of the rows containing BIO, but each college has multiple courses. I'd like to be able to find a way to automate *all* of the relevant course codes to move into the ArtsnSci sheet. Is there a way to make it transfer all rows containing, for example, BIO, HIST, PHYS, or CHEM into the ArtsnSci sheet without replacing the "BIO" in the code with "HIST" and re-running each time?