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:
- Open exported file (I know how to do this)
- For each row in exported file
- Read ticket number (column A)
- Search existing sheet column for ticket number (also column A)
- If found then replace information with imported data (columns B-X)
- Else append imported data as a new row (columns A-X)
- Next row
Steps 4-6 above are what I'd like help with. I can use a formula such as =NOT(ISNA(MATCH([imported ticket ID],[array of existing ticket IDs],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.
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.
EDIT: Here is the code I have so far. It's not much.
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