Hi,
I have the below code which looks up column headings from one sheet and pastes the columns into another sheet. It works well, apart from situations where one column has cells that are blank, in which case it only does a partial copy/paste because it stops copying when it reaches a blank cell.
In this example, the 'Date' column will never have any blank cells. Is there a way to have this code look up the range for the 'Date' column and base the copy/paste from that column range?
Thanks.
I have the below code which looks up column headings from one sheet and pastes the columns into another sheet. It works well, apart from situations where one column has cells that are blank, in which case it only does a partial copy/paste because it stops copying when it reaches a blank cell.
In this example, the 'Date' column will never have any blank cells. Is there a way to have this code look up the range for the 'Date' column and base the copy/paste from that column range?
Thanks.
VBA Code:
Dim vHeader As Variant, rngFound As Range, i As Long
For Each vHeader In Array("Date", "Time", "C", "Country/Region", "Event", "S")
Set rngFound = Sheets("BBGExport").Cells.Find(vHeader, , xlValues, xlWhole, 1, 1, 0)
i = i + 1
If Not rngFound Is Nothing Then
Range(rngFound, rngFound.End(xlDown)).Copy Destination:=Sheets("Scheduler").Cells(1, i)
End If
Next