| View previous topic :: View next topic |
| Author |
Message |
aeroian Newbie

Joined: 25 Jun 2010 Posts: 1
|
Posted: Fri Jun 25, 2010 8:48 pm Post subject: [Solved]What command to crop a cell's contents? |
|
|
Hi,
I have a column of data with cells that contain a long mix of characters and numbers...how can i crop the data in these cells to contain only the first 5 letters/numbers in the cell, and drop the rest?
I have been racking my brain as to how to do this and I was hoping folks here could help. I'm not sure what to search for so I'm sorry if this has been asked before!
Thanks
~Ian
Last edited by aeroian on Sat Jun 26, 2010 5:17 pm; edited 1 time in total |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Sat Jun 26, 2010 3:07 am Post subject: |
|
|
Select column.
Open search/replace Ctrl+F. Search for: \<(.{5}).*\> Replace with: $1
Under "More Options" check "Current selection only" and "Regular expressions".
Replace All. _________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
ken johnson Super User

Joined: 23 Apr 2009 Posts: 1851 Location: Sydney, Australia
|
Posted: Sat Jun 26, 2010 3:16 am Post subject: |
|
|
Say the values to be cropped are in column A.
In the next available empty column enter this formula...
=LEFT(TRIM(A1);5)
Fill this formula down as far as needed.
Copy the results of the formula then go Edit|Paste Special to bring up the "Paste Special" dialog. Under the "Selection" heading deselect "Paste all", select "Text strings" and deselect all the other options. Click OK.
If you a satisfied with the results you can use copy/paste to replace the original column A values with the cropped values.
Ken Johnson _________________ If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button). |
|
| Back to top |
|
 |
|