cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Steffen_Bugge
Level IV

Color cells by conditional formatting

I need a script that looks through all columns and color cells with the value "< LOD". My script does not give the desired outcome. Any advice?

dt = Current Data Table();

// Get all of the column names in the data table
ColNames = dt << get column names( string );
NRows = N Rows( dt );

// Loop through each column and row to find "< LOD" and color the previous cell
For( i = 1, i <= N Items( ColNames ), i++,
	column = Column( dt, ColNames[i] );
	For( j = 2, j <= NRows, j++, // Start at row 2 to avoid coloring out-of-bound cells
		If( Row(j) == "< LOD",
			column << Color Cells( j - 1, "Red" );
		)
	);
);
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Color cells by conditional formatting

This looks for value "F" but most likely gives some ideas what you could change (get all rows beforehand for each column, color cells argument ordering, ...)

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

colnames = dt << get column names(character, string);

For Each({colname}, colnames,
	r = Loc(dt[0, colname], "F");
	If(N Items(r) > 0,
		Column(dt, colname) << Color Cells("Red", r);
	);
);

Write();

Edit: Removed unnecessary Show(r); from the loop

-Jarmo

View solution in original post

2 REPLIES 2
Steffen_Bugge
Level IV

Re: Color cells by conditional formatting

Other and more elegant solutions are more than welcome!

jthi
Super User

Re: Color cells by conditional formatting

This looks for value "F" but most likely gives some ideas what you could change (get all rows beforehand for each column, color cells argument ordering, ...)

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

colnames = dt << get column names(character, string);

For Each({colname}, colnames,
	r = Loc(dt[0, colname], "F");
	If(N Items(r) > 0,
		Column(dt, colname) << Color Cells("Red", r);
	);
);

Write();

Edit: Removed unnecessary Show(r); from the loop

-Jarmo