Hello,
I'd like to loop through all headers in each column, and copy and paste all data below the header into another column. The header name may appear more than once in the columns and I can't figure out how to loop through all of the columns and find all instances of the header name.
This is what I have so far, but it only finds the first instance of the header name (e.g. coursename) and then stops.
Any help is appreciated!
Code:
Sub Courses()
Dim LRow As Long
Dim Found As Range
With Sheets("Sheet1")
Set Found = .Range("A1:AB1").Find("coursename")
If Not Found Is Nothing Then
LRow = .Cells(.Rows.Count, Found.Column).End(xlUp).Row
.Range(.Cells(2, Found.Column), .Cells(LRow, Found.Column)).Copy
.Cells(.Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial xlPasteValues
End If
End With
End Sub