Some writers struggle to choose between that and which. And some writers don’t struggle at all; they choose which because they think it sounds more correct or more formal. The writers in the second group are often wrong.
The wonderful writing teacher William Zinsser puts it simply: “Always use that unless it makes your meaning ambiguous.” In most situations, Zinsser says, that is what you would naturally say and therefore what you should write.
Readers who want a grammar rule for this guidance can have one. It’s a matter of restrictive clauses and nonrestrictive clauses.
That introduces restrictive clauses:
The leftover vegetables that are in the refrigerator would make a good stew.
“That are in the refrigerator” is a restrictive clause; it clarifies the specific vegetables being referred to. The writer is not referring to the vegetables that are in the root cellar; she is referring to the vegetables that are in the refrigerator.
Which is for nonrestrictive clauses:
The leftover vegetables, which are in the refrigerator, would make a good stew.
“Which are in the refrigerator” is nonrestrictive. The sentence would be clear without this clause; the clause simply provides additional information. It’s as if the writer were saying, “The leftover vegetables would make a good stew. Incidentally, they are in the refrigerator.”
This discussion of “that” versus “which,” like everything else in this blog, assumes U.S. English. Users of British English should pay no attention.