Macro Question: Get Column Name by Column Number / or Use Text constant to link on a

J

JoachimJaeger

Hello ,

I'm an engineer with the responsibility to look onto some production test data.
I'm using minitab to generate a lot of e.g. cpk plots based on production data.

The data is located in a worksheet with unique column names as below:

Counter SerialNo Operator DateTime PassFail StationID Size1 Size2 Color1 Color2 Size3 [....]
100 ABCD OP1 2014-10-20 15:17 P Station1 3000 2789 blue green 2700 [....]
101 ABCE OP1 2014-10-20 15:27 P Station1 3003 2799 blue red 2710 [....]
[...]

To generate the plots I'm using a global macro to do this.
The macro looks similar to this example:

Capa 'Size1' 1;
Lspec 2950;
Uspec 3050;
[... sub commands not mentioned her to save space]
CStat.
Capa 'Size3' 1;
Lspec 2550;
Uspec 3150;
[... sub commands not mentioned her to save space]
CStat.
[...]

The macro itself is working fine, but it is not easy to maintain. Especially if a test limit was changed or an additional test step has to be added or removed.

To improve the script I added some additional columns with following content as a lookup table
TestStep LimitLow LimitHigh
Size1 2950 3050
Size3 2550 3150

My idea was to to run a loop to all the test steps as stored in the table and use the values of the table as input.
I was able setup a loop as follows:
let k1= count('TestStep') # get the no of test steps
do k2 = 1: k1
Let k100 = TestStep[k2] # get TestStepName
Let k101 = LimitLow[k2] # get LSL
Let k102 = LimitHigh[k2] # get USL


When I now try to generate the capa as
Capa k100 1;
[...]

I got an error massage that a column was required.
Is there any possibility to use a text constant as an input for a graph e.g capa or hist?

I tried also to use a numeric input variable to generate multiple capas.
do k1 = 1: 10
Capa ck1 1;
[...]

This seems to be working. The problem is that it is not necessary to generate the plots for all of the stored data.
Due to this I considered to expand my lookup table with the column information.
TestStep LimitLow LimitHigh InColumn
Size1 2950 3050 7
Size3 2550 3150 11

Now I can use following macro:
let k1= count('TestStep') # get the no of test steps
do k2 = 1: k1
Let k100 = TestStep[k2] # get TestStepName
Let k101 = LimitLow[k2] # get LSL
Let k102 = LimitHigh[k2] # get USL
Let k103 = InColumn[k2] # get ColumnNo
Capa ck103 1;

This is my Idea for the moment. But currently I'm fighting to get the column number based on the column name. I thought about to run a loop over all used columns and compare the column name to the string in the lookup table and store the number if they fit.
My problem is that I could not find any function to get the column name by the column number.
Is there existing such functionality?
All other ideas are also welcome.

Thanks a lot
Joachim
 

Stijloor

Leader
Super Moderator
Re: Macro Question: Get Column Name by Column Number / or Use Text constant to link o

A Quick Bump!

Can someone help?

Thank you very much!!
 
Top Bottom