Rows to a new table using existing row labels

I’m trying to make a macro to search through the text in each label key words and sum the areas of specific labels. I’ve been trying to do this by creating another table and copying the “searched” rows to another table but can’t figure it out. Any help would be greatly appreciated.

Hi @Daniel1,

in the macro language this is not so trivial because the command getResult() and setResult()only works for a table with the name Result. You can constantly alternatingly rename the tables but this is slow and not recommendable.

Here is what I would suggest:

You make a for loop and cycle through your results table calling

label = getResultLabel(row) into a variable.

Then make your test on the String (text) to see if your keyword is contained in it with indexOf(label, "yourKeyWord").

If your keyword is not contained it will return -1 otherwise its position in the text.

If your result is NOT -1 you simply transfer your area of this respective row in a new column.

for(i=0; i<nResults; i++) {
	if(indexOf(getResultString("Label", i), "yourKeyWord") != -1) {
		setResult("YourColumnLabel", i, getResult("Area", i));
	}
}

For each keyword you can make a new column like this

Therafter, save the table and sum it in e.g. Excel

1 Like