EX-23 5 d667935dex23.htm EX-23

Exhibit 23

Consent of Independent Registered Public Accounting Firm

We consent to the incorporation by reference in the following Registration Statements:

| • |  | Registration Statements (Form S-8, No. 333-76847, 333-83998, 333-124685, and 333-150690) pertaining to the amended and restated 2023 Stock Option and Incentive Plan of Trex Company, Inc., and

of our reports dated February 26, 2024, with respect to the consolidated financial statements of Trex Company, Inc. and the effectiveness of internal control over financial reporting of Trex Company, Inc. included in this Annual Report (Form 10-K) of Trex Company, Inc. for the year ended December 31, 2023.

/s/ Ernst & Young LLP

Tysons, Virginia

February 26, 2024