Hi, thanks to some help I got this code running. This code copiy/pastes new columns (not yet existing) from sheet "List" to sheet "Students".
This all works fine for sheet "Students". But I want to run this code for every sheet with a name that is listed in sheet "Sheetnames", range F2:F39.
How do I go about this? I'm not sure where to go... Many thanks in advance for helping me as a newbie in vba.
VBA Code:
Dim wb As Workbook: Set wb = ThisWorkbook
With wb
Dim LastTemplateCol As Long: LastTemplateCol = .Worksheets("List").Cells(1, Columns.Count).End(xlToLeft).Column
For i = 2 To LastTemplateCol
Dim TempTask As String: TempTask = .Worksheets("List").Cells(1, i).Value
Dim LastStudentCol As Long: LastStudentCol = .Worksheets("Students").Cells(1, Columns.Count).End(xlToLeft).Column
For t = 2 To LastStudentCol
Dim StudTask As String: StudTask = .Worksheets("Students").Cells(1, t).Value
Dim Exists As Boolean: Exists = False
If TempTask = StudTask Then
Exists = True
GoTo taskloop:
Else
GoTo studloop:
End If
studloop:
Next t
If Exists = False Then
.Worksheets("List").Cells(1, i).Columns.EntireColumn.Copy
.Worksheets("Students").Cells(1, LastStudentCol + 1).PasteSpecial
End If
taskloop:
Next i
End With
This all works fine for sheet "Students". But I want to run this code for every sheet with a name that is listed in sheet "Sheetnames", range F2:F39.
How do I go about this? I'm not sure where to go... Many thanks in advance for helping me as a newbie in vba.