Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I sort numbers based on last two digits?

I am working on a hospital project. Casenotes are stored by a 3 dual digit
system eg. 23 44 67 with casenotes ending in ** ** 68 and ** ** 66 stored
adjacent. Get it? I have a load of notes to look up so I need to sort out the
casenote numbers I have by the last two digits in order to simplify the
manual search for the notes. Is there any way I could program the Excel list
I have to sort the last two digits of the casenote numbers into numerical
order?
  #2   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default How do I sort numbers based on last two digits?

Wallaby,

The following code assumes all your data is in one list and the case
notes are in the first row, and all data is on sheet1

sub sort()
nurec = sheet1.usedrange.rows.count
for t = 1 to nurec
for y = 1 to nurec
casno = right(cells(y,1),2)
casnonex = right(cells(y+1,1),2)
if casnonex casno then goto nexty
rows(trim(str(y))).copy
rows(trim(str(nurec+6))).select
activesheet.paste
rows(trim(str(y+1))).copy
rows(trim(str(y))).select
activesheet.paste
rows(trim(str(nurec+6))).copy
rows(trim(str(y+1))).select
activesheet.paste
rows(trim(str(nurec+6))).clear
nexty:
next y
next t
end sub
note this sub is completely untested and i may have misunderstood your
criteria, run on a backup copy first

"The Wallaby" wrote:

I am working on a hospital project. Casenotes are stored by a 3 dual digit
system eg. 23 44 67 with casenotes ending in ** ** 68 and ** ** 66 stored
adjacent. Get it? I have a load of notes to look up so I need to sort out the
casenote numbers I have by the last two digits in order to simplify the
manual search for the notes. Is there any way I could program the Excel list
I have to sort the last two digits of the casenote numbers into numerical
order?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I sort a list of numbers by the last 4 digits? Kristin S Excel Worksheet Functions 3 May 19th 09 01:30 AM
How can I sort a list of numbers by the last 4 digits? Kristin S[_2_] Excel Discussion (Misc queries) 1 May 18th 09 07:29 PM
sort by numbers of digits in cells mab2819 Excel Worksheet Functions 4 August 20th 08 10:38 PM
Auto insert page breaks in Excel, based on a sort of numbers peterc89 Excel Discussion (Misc queries) 0 November 9th 05 03:41 PM
sort numbers based on initial digit. Andyd Excel Discussion (Misc queries) 2 June 28th 05 01:20 PM


All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"