Hello kjy1989,
Using formulas to create a database is like the little pig that built his house from straw. While formulas are easy and familiar, they can not guard against the potential problems that databases encounter. It is more work to do it using VBA but provides you with a robust environment that will protect your database. Now your house is not only brick, it is reenforced with rebar.
This macro reads the database from a custom text file into a public collection named "Ingredients" and the file is then closed. The ingredient list is returned as a comma separate string when a recognized Order Code is used. This safeguards the database in several ways. The database file is read only using the macro preventing the user from changing anything. The database file is closed after being read which prevents accidental corruption of the data should Excel crash. Closing the file after reading also allows multiple users to have access to the database with no need for passwords.
ThisWorkbook Module Macro
The custom text file is named Restaurant.dbt. Currently, the macro looks for the this file in the same folder as the workbook. The first line identifies the file as the database file. The order code must be followed by a pipe character and then the ingrediants list which is separated by commas.
To edit this file use NotePad. When you select this file, Windows will ask you how you want to open the file. Select "Choose program" and select NotePad. You can make additional entries and save them. Just be sure to follow the format as outlined.
The macro will alert you to errors in the file and provide you with the line number in the file where the error was found. You will be asked if want to continue running the macro after an error has occurred.
Custom Database Text File
Bookmarks