title: VBA to import Excel worksheet, append new rows, and update existing rows
body: <p>I'm using Excel to produce reports for a support ticketing system, and I'd like to use VBA to simplify the process of updating the report data. What I want to do is import an Excel file dumped from the ticketing system into the Excel file I'm using for reporting, but with a twist. I need to use the value in one column to identify whether the ticket is new or existing. If it's new, I want to add it to the reporting file. If it's existing, I want to overwrite the matching row (based on the matching column value, which is the ticket number) with the imported data. So the basic process would be:</p>
  
  <ol>
  <li>Open exported file (I know how to do this)</li>
  <li>For each row in exported file</li>
  <li>Read ticket number (column A)</li>
  <li>Search existing sheet column for ticket number (also column A)</li>
  <li>If found then replace information with imported data (columns B-X)</li>
  <li>Else append imported data as a new row (columns A-X)</li>
  <li>Next row</li>
  </ol>
  
  <p>Steps 4-6 above are what I'd like help with. I can use a formula such as =NOT(ISNA(MATCH([<em>imported ticket ID</em>],[<em>array of existing ticket IDs</em>],0))) to return TRUE if the ticket ID exists and FALSE if it doesn't, but would like to find a more elegant solution if one exists.</p>
  
  <p>Does anyone here have experience with doing this and/or some VBA code I might be able to tweak to suit my purposes? Thanks in advance.</p>
  
  <p>EDIT: Here is the code I have so far. It's not much.</p>
  
  <pre><code>Sub UpdateTickets()
  'Specify data export file
  Dim fNameAndPath As Variant
  fNameAndPath = Application.GetOpenFilename(Title:="Select File To Be Processed")
  If fNameAndPath = False Then Exit Sub
  'Open data export file
  Workbooks.Open Filename:=fNameAndPath
  'For each row in data export file, starting at Row 2
  'Check master data file (column A) for ticket number
  'If ticket number exists, update information in columns B through P
  'Else add new ticket row and place information in columns A through P
  'Next row
  End Sub
  </code></pre>