- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Color cells by conditional formatting
Created:
Oct 26, 2024 02:34 PM
| Last Modified: Oct 26, 2024 11:37 AM
(512 views)
| Posted in reply to message from Steffen_Bugge 10-26-2024
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
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Color cells by conditional formatting
Created:
Oct 26, 2024 02:29 PM
| Last Modified: Oct 26, 2024 11:30 AM
(514 views)
| Posted in reply to message from Steffen_Bugge 10-26-2024
Other and more elegant solutions are more than welcome!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Color cells by conditional formatting
Created:
Oct 26, 2024 02:34 PM
| Last Modified: Oct 26, 2024 11:37 AM
(513 views)
| Posted in reply to message from Steffen_Bugge 10-26-2024
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