I revised my original design to incorporate your specifications, but I used a MultiPage control to allow use of just one form instead of three. MultiPage1 of the form is where you enter engine model/make/horsepower configurations. MultiPage2 of the form is where you enter Compressor model/make configurations. MultiPage3 of the form is where you enter Throw/Stage configurations (Throws = 1 to 9, Stages = 2 to 9).
My revised solution now has three worksheets:
1) The 'Engines' worksheet contains unique Engine model/make/horsepower configurations with a two-digit ID number assigned automatically when new data is added.
2) The 'Compressors' worksheet contains unique Compressor model/make configurations with a two-digit ID number assigned automatically when new data is added.
3) The 'Configurations' worksheet contains all of the data for any configuration you create with an eight-digit ID number assigned automatically using your XXYYAB00 numbering methodology (XX = EngineID, YY = CompressorID, A = Throws, B = Stages, 00 = ConfigID).
The form will not allow data to be written to the worksheets unless values are selected/created in every field on the form. The code will only allow unique engine model/make/horsepower configurations to be added to the 'Engines' worksheet, and only unique compressor make/model configurations to be added to the 'Compressors' worksheet. You will get an alert in either/both cases if duplicate data was added in the form page(s) when form data is uploaded to the worksheets. It will create a new configuration in the 'Configurations' worksheet (sequentially numbered 00, 01, 02, etc.) even if a matching configuration has already been created.
See the attached .zip file 'Revised Solution' to extract the 'Engines2.xls' file.
(I left the original UserForm in the revised version for code comparison.) To execute the new version, run macro 'enterData2'.
NOTE: I always try to post the VB code directly in the thread, but the length of the code exceeds the limitation of the total number of characters allowed (10,000) in a thread, so you will have to extract the sample file to view it. To the best of my knowledge, no malicious spyware, viruses, etc. exist in the .zip file contents or the VB code.
Enjoy!
theDude
Bookmarks