I have an excel macro which our Finance team will use to convert an excel file to a particular format (comma delimited txt) so they can import the data to our system. The macro works great, with one exception. The final file needs to have 5 fields: Account Number, Card Number, Date, Transaction Code, Amount.
Only the Account Number OR the Card Number is mandatory - you don't need both. The problem is that when saving an Excel file as a comma delimited file (manually or using the macro) and there are no Account Numbers (i.e. all the records use only card numbers) then the first column is blank (file has no header), and the comma delimited file is then saved with only 4 fields, starting at the card number - it should start with a blank field, i.e. with an immediate comma - our system is now rejecting these files.
It saves like this:
1944210004744845,20092014,931,2191.33
It should save like this:
,1944210004744845,20092014,931,2191.33
As long as there is one account number somewhere in the first column everything is okay.
I don't want our developers to make changes, so I was thinking of adding a piece to the end of the macro, after saving the txt file, which will count the number of commas in the first row of the txt file, and IF there are only 3 commas, it must add a comma before every record in the file.
Could someone perhaps help with this, as I have no idea how to do that. Or perhaps there is a better way?