How would I create a table of measurement results?

Hello!

I’m trying to make a macro that selects a 10x10 grid of pixels and measures the intensity at each grid, then applies it to each image in a stack of 20 images. I have it so that it runs through the stack, but the measurements come out as a single column whereas I want it in a 20x100 table, i.e. each image in the stack is in its own column. From there I can copy it into excel and find the standard deviation of each pixel. I’ve heard using setResults might be able to do this, but haven’t been able to figure it out. Any help would be appreciated! My code right now is:

macro "ROI Grid measurement stack"

{
	//define number of slices in stack
	slices=nSlices

	for (n=1; n<nSlices+1; n++) 
	{
		Stack.setSlice(n);
		roiManager("reset")
		x = 70;
		y = 70;
		width = 1;
		height = 1;
		spacing = 35;
		numRow = 10;
		numCol = 10;

		for(i = 0; i < numRow; i++)
		{
			for(j = 0; j < numCol; j++)
			{
				xOffset = j * (width + spacing);
				print(xOffset);
				yOffset = i * (height + spacing);
				print(yOffset);
				makeRectangle(x + xOffset, y + yOffset, width, height);		
				roiManager("Add");
			}
		}
		roiManager("Show All");
		roiManager("Measure");
}

I’m not sure if I can attach a stack here, but if sample data is needed please let me know.

Thank you in advance!