Gross margin was 45.4%, a 580-basis-point expansion from 39.6% in the first quarter of 2023, and above expectations. Increased capacity utilization, along with related production efficiencies and the continued benefit of cost-out programs, were the key drivers of this exceptional margin performance, which more than offset higher labor costs. I continue to be impressed by the discipline and the success the Company has around continuous improvement programs. It is part of our DNA and is embraced at all levels within the organization. As Bryan noted, while we do not expect to replicate this margin level in subsequent quarters this year, it is a good indicator of our ability to drive substantial operating leverage.
Selling, general, and administrative expenses were $51 million, or 13.5% of net sales, in the first quarter compared to $37 million, or 15.7% of net sales, a year ago, representing considerable leverage as a percent of sales due to the strong sales performance in this year’s first quarter. The year-over-year dollar increase is primarily due to accelerated branding and marketing spend mainly related to new product launches and preparing for the busy season. We made the decision in 2023 to increase our branding spend back to historical levels. As we continue to invest at this level in 2024, we see evidence of it helping to drive the market to Trex products.
Net income was $89 million in the first quarter, or $0.82 per diluted share, more than double the $41 million, or $0.38 per diluted share, reported last year. We delivered EBITDA of $133 million, or 35.6% of net sales, compared to $69 million, or 28.8% of net sales, in the year-ago quarter, driven by increased sales volume and higher gross margins.
Consistent with historical trends, first quarter cash flow from operations represented a use of cash, primarily for working capital needs. Cash used in operations was $174 million, compared to cash used in operations of $115 million in 2023, primarily due to the shift in timing of the Early Buy program and subsequent increase in Q1 sales volume.
We invested $38 million in capital expenditures, primarily related to the build-out of the Arkansas manufacturing facility.
As noted in today’s earnings release, our first quarter results support our expectations for substantial, above market growth in 2024. We are pleased to reaffirm our full year guidance for this year. We expect net sales to range from $1.215 billion to $1.235 billion, representing year-on-year growth of 12% at the midpoint. EBITDA margin is expected to range from 30.0% to 30.5%.
Full year SG&A expenses are expected to drive 20 to 30 basis points of leverage and we are assuming an effective tax rate of approximately 25% to 26%. With our Early Buy program completed in Q1, we expect Q2 sales in the range of $380 million to $390 million.
With that, I’ll now turn the call back to Bryan for his closing remarks.
Bryan Fairbanks
Thank you, Brenda. As I noted in our last conference call, I have a high level of confidence in the Trex consumer, in our brand, our products and product development capabilities, our channel partners, and Trex’s growth potential. Our first quarter results have only strengthened that confidence.
Trex is well positioned to continue to benefit from the strength of the Outdoor Living category, and new product introductions are further distinguishing us from a competitive standpoint. Our channel partners are best in the industry, Trex products are available at over 6,700 locations – far more than any other brand in our industry, and consumer recognition of the attributes of Trex decking and railing products continues to build. We are looking ahead for a year of strong growth for Trex in 2024 and to capturing a greater share of the much-larger addressable market in the coming years.
4