Personally for tasks like this that are essenially outputting a varying number of rows from a database to a pre-defined form as you have with sheet1 I use an Advanced Data Filter which is run by a simple two line VBA macro.
The requirement to allow you to do this is that the labels in B25:G25 MUST MATCH EXACTLY the column labels in your database (i.e. the Firm sheet). Where you have labels like Item Qty (which you presumably fill in after data has been extracted) then you should include that as a column header in your data eveb though the column will be blank.
For any task like this it's always useful to apply a dynamic range name to your data. In this case I've created a name callled 'DATA' and defined it as
and that name is used in the formula below.
The stuff at the top of Sheet1 that's dependent on the order number can be populated with an INDEX(MATCH()) combination of formulae. For instance
With 'ORNo.' in A4 and 'Customer Ref' in A6 then the C6 formula would be
The other fields at the top can be populated in a similar way.
I've made your Data column labels match your sheet1 labels, named B23:G23 'DataOut' and A4:A5 'Crit'.
Now when you select or enter an order number in C4 the folloiwng macro will run and populate your form.
Bookmarks