TRIMRANGE function

Category: Lookup and reference
Introduced: Excel 365

Summary

Scans in from the edges of a range or array until it finds a non-blank cell (or value), it then excludes those blank rows or columns

Syntax

The TRIMRANGE function scans in from the edges of a range or array until it finds a non-blank cell (or value), it then excludes those blank rows or columns. ​​​​​​​
=TRIMRANGE(range,[trim_rows],[trim_cols])
range Required | The range (or array) to be trimmed
trim_rows | Determines which rows should be trimmed 0 - None 1 - Trims leading blank rows 2 - Trims trailing blank rows 3 - Trims both leading and trailing blank rows (default)
trim_columns | Determines which columns should be trimmed 0 - None 1 - Trims leading blank columns 2 - Trims trailing blank columns 3 - Trims both leading and trailing blank columns (default)

Example

=TRIMRANGE(range,[trim_rows],[trim_cols])



Argument


Description



range

Required

The range (or array) to be trimmed



trim_rows

Determines which rows should be trimmed

0 - None

1 - Trims leading blank rows

2 - Trims trailing blank rows

3 - Trims both leading and trailing blank rows (default)


trim_columns

Determines which columns should be trimmed

0 - None

1 - Trims leading blank columns

2 - Trims trailing blank columns

3 - Trims both leading and trailing blank columns (default)




Trim References (aka Trim Refs)

A Trim Ref can be used to achieve the same functionality as TRIMRANGE more succinctly by replacing the range's colon ":" with one of the three Trim Ref types described below:



Type


Example


Equivalent TRIMRANGE


Description



Trim All (.:.)

A1.:.E10

TRIMRANGE(A1:E10,3,3)

Trim leading and trailing blanks


Trim Trailing (:.)

A1:.E10

TRIMRANGE(A1:E10,2,2)

Trim trailing blanks


Trim Leading (.:)

A1.:Z10

TRIMRANGE(A1:E10,1,1)

Trim leading blanks


This pattern can also be applied to full-column or -row references (eg. A:.A)







Need more help?





Want more options?



DiscoverCommunity



Explore subscription benefits, browse training courses, learn how to secure your device, and more.






Microsoft 365 subscription benefits




Microsoft 365 training




Microsoft security




Accessibility center


Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.






Ask the Microsoft Community




Microsoft Tech Community




Windows Insiders




Microsoft 365 Insiders
















Was this information helpful?

Yes No


Thank you! Any more feedback for Microsoft? Can you help us improve? (Send feedback to Microsoft so we can help.)

What affected your experience?


Resolved my issue

Clear instructions


Easy to follow

No jargon


Pictures helped

Other



Didn't match my screen

Incorrect instructions


Too technical

Not enough information


Not enough pictures

Other

Any additional feedback? (Optional) To protect your privacy, do not provide any personal information such as email address, phone number, product key, password, or credit card number.

Submit feedback

By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.


Thank you for your feedback!
×







What's new
Surface Pro
Surface Laptop
Surface Laptop Studio 2
Copilot for organizations
Copilot for personal use
AI in Windows
Explore Microsoft products
Windows 11 apps


Microsoft Store
Account profile
Download Center
Microsoft Store support
Returns
Order tracking
Certified Refurbished
Microsoft Store Promise
Flexible Payments


Education
Microsoft in education
Devices for education
Microsoft Teams for Education
Microsoft 365 Education
How to buy for your school
Educator training and development
Deals for students and parents
AI for education



Business
Microsoft Cloud
Microsoft Security
Dynamics 365
Microsoft 365
Microsoft Power Platform
Microsoft Teams
Microsoft 365 Copilot
Small Business


Developer & IT
Azure
Microsoft Developer
Microsoft Learn
Support for AI marketplace apps
Microsoft Tech Community
Microsoft Marketplace
Marketplace Rewards
Visual Studio


Company
Careers
About Microsoft
Company news
Privacy at Microsoft
Investors
Diversity and inclusion
Accessibility
Sustainability

English (United States)

Microsoft Support Page

https://support.microsoft.com/en-us/office/trimrange-function-d7812248-3bc5-4c6b-901c-1afa9564f999

Back to Functions