Search code examples
vbacsvsplitrowdelete-row

Remove first row after executing Split function in Excel VBA


How do I remove the first row after executing the following Split function in Excel VBA:

Dim testtext As String
Dim csv_rows() As String
csv_rows() = Split(testtext, Chr(10))

Reason being that the first row is the column header names which I wish to remove. I tried csv_rows() = Split(text, Chr(10)) - 1 but it does not seem to work.


Solution

  • Try this way, please:

    csv_rows = Filter(csv_rows, csv_rows(0), False)
    

    If it is possible that another line (array element) to be identic with the first one, this way will make it working safer:

    csv_rows(0) = csv_rows(0) & "####" 'this line can be missing if no any risk that a similar line with the first one exists.
    csv_rows = Filter(csv_rows, csv_rows(0), False)