Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looking for a more elegant way to program code
I wrote a routine to do the following – and it works fine, but I was
trying to be a bit elegant with my code. Can anyone give me some direction if the way I wanted to program the routine can be done. Here’s the problem I was coding a solution for: I have an array that contains a list of products. For each customer, a variable number of unique products are pulled and the pull order has to be maintained. Additionally, the products are grouped for each customer. So, a code in the form of “X.YY” is created for each customer, where X is the group 1, 2, 3 … alpha, beta, etc… (alphas have to follow numerics) . YY is the sequential order of the products for each individual customer. So, the data array has the product list going down the rows, while each column is the specific customer with the X.YY code against those products that comprise that order. When I print out any customer’s order, the required format is a heading for each group (starting with numerics, e.g. “Group 1, Group 2, etc”) and the product list in the sequential order. I accomplished this by sorting the specific customer column in ascending order, reading each product into a temporary array (along with the X.YY code), then running each row of the temp array through a series of 'if' statements to print the product list. As each group is changed (“X”), a new section header (“Group “ & X) would be printed, followed by the product list. If the group was an alpha, it would just print the alpha. I got the code running with no problems using a number of if statements (if X= number, if X= alpha, etc) and a lot of redundant lines of code, but I was hoping to program something that would recognize the change in group designation and make a few branch changes, without a whole lot of software repeated. Any suggestions? Art |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"=" in text file formatting messes with my code loop- more elegant (and faster) solution? | Excel Programming | |||
Is there an elegant way? | Excel Discussion (Misc queries) | |||
Need More Elegant Solution - Simple Program | Excel Programming | |||
More elegant way to do IF () | Excel Worksheet Functions | |||
More elegant method? | Excel Worksheet Functions |