ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trim all but the first 5 characters in cell (https://www.excelbanter.com/excel-programming/323693-trim-all-but-first-5-characters-cell.html)

Annette[_5_]

Trim all but the first 5 characters in cell
 
How would I write the trim to leave only the first five characters in a
column?



Tom Ogilvy

Trim all but the first 5 characters in cell
 
Dim rng as Range, cell as Range
With Activesheet
set rng = Intersect(.usedRange,.columns(5)).Cells
End With
for each cell in rng
cell = Left(cell.Text,5)
Next

--
Regards,
Tom Ogilvy

"Annette" wrote in message
...
How would I write the trim to leave only the first five characters in a
column?





Annette[_5_]

Trim all but the first 5 characters in cell
 
that does the trick .. thanks!
"Tom Ogilvy" wrote in message
...
Dim rng as Range, cell as Range
With Activesheet
set rng = Intersect(.usedRange,.columns(5)).Cells
End With
for each cell in rng
cell = Left(cell.Text,5)
Next

--
Regards,
Tom Ogilvy

"Annette" wrote in message
...
How would I write the trim to leave only the first five characters in a
column?








All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com