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 22 December 2003, 12:14 PM
  #1  
Fig
Scooby Regular
Thread Starter
 
Fig's Avatar
 
Join Date: Aug 2002
Location: not forgetting 20,000 posts from last time ;)
Posts: 5,806
Likes: 0
Received 0 Likes on 0 Posts
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) ?
Old 22 December 2003, 12:28 PM
  #2  
DJ Dunk
Moderator
Support Scoobynet!
iTrader: (5)
 
DJ Dunk's Avatar
 
Join Date: Nov 2001
Location: Not all those who wander are lost
Posts: 17,863
Received 0 Likes on 0 Posts
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.
Old 22 December 2003, 12:52 PM
  #3  
Fig
Scooby Regular
Thread Starter
 
Fig's Avatar
 
Join Date: Aug 2002
Location: not forgetting 20,000 posts from last time ;)
Posts: 5,806
Likes: 0
Received 0 Likes on 0 Posts
Post

Could you explain how I do the text-to-columns split please?
Old 22 December 2003, 12:59 PM
  #4  
DJ Dunk
Moderator
Support Scoobynet!
iTrader: (5)
 
DJ Dunk's Avatar
 
Join Date: Nov 2001
Location: Not all those who wander are lost
Posts: 17,863
Received 0 Likes on 0 Posts
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.
Old 22 December 2003, 01:04 PM
  #5  
markr1963
Scooby Regular
 
markr1963's Avatar
 
Join Date: Jun 2002
Location: Perth, Western Australia
Posts: 1,866
Likes: 0
Received 0 Likes on 0 Posts
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
Old 22 December 2003, 01:25 PM
  #6  
DJ Dunk
Moderator
Support Scoobynet!
iTrader: (5)
 
DJ Dunk's Avatar
 
Join Date: Nov 2001
Location: Not all those who wander are lost
Posts: 17,863
Received 0 Likes on 0 Posts
Thumbs up

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

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



Quick Reply: Can this be done in Excel?



All times are GMT +1. The time now is 11:52 PM.