title: Find last row in CSV database from Excel VBA
body: <p>I am reading a .csv database in excel, because I am using an external database.</p>
  
  <p>I dont want to copy anything into the excel application, I either want to read from the database(and maybe change some values), or add to it.</p>
  
  <p>I have a textbox in a userform that should get the value of the last entry in "column" A(A reference number), and add one to it(this is for the next entry in the database).</p>
  
  <p>I want to find the last row in a semicolon split CSV database using excel VBA.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>Dim FilePath As String
  
  FilePath = "L:\database.csv"
  Open FilePath For Input As #1
      Do While Not EOF(1)
          linenumber = linenumber + 1
          Line Input #1, Line
          arrayOfElements = Split(Line, ";")
  
          elementnumber = 0
  
          testValue = arrayOfElements(0)
  
          If testValue = "L51599" Then
  
             refnr.Text = testValue
          Else
              'do nothing
          End If
  
      Loop
  Close #1
  </code></pre>
  
  <p>Any tips?</p>
  
  <p>Thanks</p>