• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Choosing only data that is available - Excel

Hello

I am working on a ordering process and trying to automate it.  I will give you an example of what I am trying to do below.

When I receive orders for some of my products I place the order in an Excel spreadsheet (address, order #, qty of each product).  For each order, it is placed in one row, so if I have an order going to John Smith and he orders 3 out of the 20 products that I have to offer these are all inserted in the same row.  From there I run a mail merge in Word to generate a packing list/invoice.  What I am looking to do is make it so only the products that are ordered show up on the invoice without specifying a specific place on the Word template for each product.  

Is there a Macro that I could use to make this happen?

Please let me know if you need more info.

Best Regards
wdelaney
0
wdelaney05
Asked:
wdelaney05
1 Solution
 
Patrick MatthewsCommented:
Hi wdelaney05,

I would recommend you rethink the way this works.  From your description, it shounds like each product
occupies a different column.  From a data modeling perspective, this is a bad choice.

In my opinion, you will be far better off in the long run by using a database app instead.  Access actually
comes delivered with a simple order entry template that I suspect will handle your needs with just a little
tweaking.

Regards,

Patrick
0
 
GrahamSkanCommented:
However, Word mailmerge is not designed to work with the one-to-many query that would be necessary to join the customer details to the order details, so you would have to use Access reporting. There's nothing wrong with that in the long run, but you would have to familiarise yourself with quite a lot.

Meanwhile...

Presumably you have a very limited number of products.

You could make each item only show if the quantity is greater than 0. This requires your MAILMERGE fields to be nested inside IF fields. It would be best to show the field codes (Alt+F9 toggles on and off). Do not type the {} pairs in, either enter them with Ctrl+F9 or as part of a field insertion.

{ IF { MAILMERGE "qtyA" } > 0 { MAILMERGE "ProductA" } "" }                 { IF { MAILMERGE "qtyA" } > 0 { MAILMERGE "qtyA"} "" }
{ IF { MAILMERGE "qtyB" } > 0 { MAILMERGE "ProductB" } "" }                 { IF { MAILMERGE "qtyB" } > 0 { MAILMERGE "qtyB"} "" }  

In Word 2000, you get an option to supress any blank lines that might result. In Word 2003 it's done without asking.

 
0
 
wdelaney05Author Commented:
Thanks you two for the answers.  I agree with you on the Access database.  That is something I need to do some more research on to utilize.  

Best Regards,
wdelaney05
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now