Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Can this be done in Excel?

Thread Tools
 
Search this Thread
 
Old Dec 22, 2003 | 12:14 PM
  #1  
Fig's Avatar
Fig
Thread Starter
Scooby Regular
 
Joined: Aug 2002
Posts: 5,806
Likes: 0
From: not forgetting 20,000 posts from last time ;)
Post

I have a column in a table which contains an alpha-numeric string. I need to sort by this column, but because some of the numeric part is 3 digits, and some 4, it is sorting ABC1000 before ABC101. Some rows also contain longer text entries, which I can ignore, so the ones I want to work with all start with "ABC"

Is it possible to check the length of the cell contents and if this is 6 characters/digits, and the first three characters are "ABC", then to insert an additional zero as the 4th character (so that ABC100 becomes ABC0100) ?
Reply
Old Dec 22, 2003 | 12:28 PM
  #2  
DJ Dunk's Avatar
DJ Dunk
Moderator
20 Year Member
iTrader: (5)
 
Joined: Nov 2001
Posts: 17,864
Likes: 0
From: Not all those who wander are lost
Smile

Not sure if it can be done with a function. But personally, I would split the column using text-to-columns into single characters per column, sort by the last column and insert the zeros. Then concatenate them back afterwards.
Reply
Old Dec 22, 2003 | 12:52 PM
  #3  
Fig's Avatar
Fig
Thread Starter
Scooby Regular
 
Joined: Aug 2002
Posts: 5,806
Likes: 0
From: not forgetting 20,000 posts from last time ;)
Post

Could you explain how I do the text-to-columns split please?
Reply
Old Dec 22, 2003 | 12:59 PM
  #4  
DJ Dunk's Avatar
DJ Dunk
Moderator
20 Year Member
iTrader: (5)
 
Joined: Nov 2001
Posts: 17,864
Likes: 0
From: Not all those who wander are lost
Smile

1) Highlight the column in question
2) Ensure you have enough spare, empty columns to the right of the selected column to take the data.
2) Choose Data, Text To Columns
3) Choose Fixed Width
4) Put break points after each character
5) Set them all to text (or else you'll lose your zeros).
6) Job done

Then you can sort by the last column and it will bring all the ones that are short to the top (or bottom). Then you can insert cells and shift to the right and add the required number of zeros. Then use the concatenate function on the columns and cut & paste the values back into the original column.
Reply
Old Dec 22, 2003 | 01:04 PM
  #5  
markr1963's Avatar
markr1963
Scooby Regular
 
Joined: Jun 2002
Posts: 1,866
Likes: 0
From: Perth, Western Australia
Post

I'd insert a column after the one you want to sort then use a formula such as this
=LEFT(A1,3) & IF(LEN(A1)=6, "0"& RIGHT(A1,3), RIGHT(A1,4))
This takes the first 3 chars (abc) and checks the length of the text. If its 6 then it appends 0 and the 3 chars from the right. If > 6 it appends 4 chars from right.

Copy the formula down the column, sort your data on this column then hide it

HTH

Mark
Reply
Old Dec 22, 2003 | 01:25 PM
  #6  
DJ Dunk's Avatar
DJ Dunk
Moderator
20 Year Member
iTrader: (5)
 
Joined: Nov 2001
Posts: 17,864
Likes: 0
From: Not all those who wander are lost
Thumbs up

Good one Mark That'll save me some time text-to-columning
Reply
Old Dec 22, 2003 | 02:47 PM
  #7  
Fig's Avatar
Fig
Thread Starter
Scooby Regular
 
Joined: Aug 2002
Posts: 5,806
Likes: 0
From: not forgetting 20,000 posts from last time ;)
Post

Thanks both - worked a treat and saved lots of clicking and editing
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
Dec 28, 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
Nov 18, 2015 07:03 AM
leg200
Subaru Parts
5
Oct 7, 2015 07:31 AM
has-scooby
Subaru Parts
4
Oct 6, 2015 03:47 PM
bluebullet29
General Technical
9
Oct 5, 2015 02:17 PM




All times are GMT +1. The time now is 02:23 AM.