Trim column lengths for every column

jsharpe

New Member
Joined
Jun 6, 2024
Messages
7
Office Version
  1. 365
Platform
  1. Windows
HI All,

below is an example of the workbooks im working on. you will see in row 4 that it has the max length of each column. is there a way to trim the length of each column easier than doing 1 column at a time?

PurchaseOrderLine.xlsx
ABCDEFGHIJKL
1Import Set NoLine NumberItem IDUnit of MeasureUnit QuantityPricing UnitUnit Price DisplayRequired DateDate DueExtended DescriptionSupplier Ship DateRevision Level
2AlphanumericDecimalAlphanumericAlphanumericDecimalAlphanumericDecimalDateDateAlphanumericDateAlphanumeric
3RequiredNot RequiredRequiredRequiredRequiredNot RequiredNot RequiredNot RequiredNot RequiredNot RequiredNot RequiredNot Required
4819408486DateDate255Date20
5S13DRILL381Each6Each5.7510/10/1910/10/193/8 Inch 12V Cordless Drill, Keyless Chuck, Case.10/10/191A
Sheet1
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Some should be able to help if they know:

"max length of each column" Means what?

"trim the length" Means what?

What do 8, 19, 40, 8, 4, 8, 6, Date, Date etc. in Row 4 signify?

How does "Date" relate to max length?
 
Upvote 0
The LEFT function will give you the leftmost n number of characters. If you wanted to return the trimmed cells in another cell the format would be as in row 8 below. There's probably a way to do it with VBA if you wanted to do it within the existing cells (but I am very novice with VBA, so someone else would have to help you there).

2024-06-19_2.xlsx
ABCDEFGHIJKL
1Import Set NoLine NumberItem IDUnit of MeasureUnit QuantityPricing UnitUnit Price DisplayRequired DateDate DueExtended DescriptionSupplier Ship DateRevision Level
2AlphanumericDecimalAlphanumericAlphanumericDecimalAlphanumericDecimalDateDateAlphanumericDateAlphanumeric
3RequiredNot RequiredRequiredRequiredRequiredNot RequiredNot RequiredNot RequiredNot RequiredNot RequiredNot RequiredNot Required
4819408486DateDate255Date20
5S13DRILL381Each6Each5.7543748437483/8 Inch 12V Cordless Drill, Keyless Chuck, Case.437481A
6
7
8S13DRILL381Each6Each5.7543748437483/8 Inch 12V Cordless Drill, Keyless Chuck, Case.437481A
Sheet2
Cell Formulas
RangeFormula
A8:L8A8=IF(ISNUMBER(A4),LEFT(A5,A4),A5)
 
Upvote 0
Hi,
the max length means the max character count in the cell.

"trim the length" Means what? shorten the character count to the max length allowed for the import.

What do 8, 19, 40, 8, 4, 8, 6, Date, Date etc. in Row 4 signify? these are the max lengths for each column.

How does "Date" relate to max length? The Date does not relate to the max length, this column will need to be ignored as it just the standard short date needed in the column.

Thanks
Josh
 
Upvote 0
Could you provide a more representative example along with the expected result?
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top