I am looking to combine specific columns in a table, specified by the column header, into one column outside of the table. So far I have the below script that works okay except that it combines adjacent columns only and the column numbers are static.
I would like to develop the script so that it works with non-continuous ranges based the column header names. I was going to use a helper column to list the column headers to combine. The below screenshot shows an example where in the helper column H three column headers have been listed (in reality the number of column headers listed will vary) and based on this the data in those columns have been combined to form a new consolidated list in column J. I would like to achieve this using VBA rather than Power Query due to earlier versions of Excel.
Sub combine()
Dim LR As Long, i As Long
For i = 1 To 6
LR = Cells(Rows.Count, i).End(xlUp).Row
Range(Cells(2, i), Cells(LR, i)).Copy _
Destination:=Cells(Rows.Count, 10).End(xlUp).Offset(1)
Next i
End Sub

