Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Sorting a Worksheet by the first 14 characters in Column A

Good morning

Currently, each day I am required to sort and "clean" an Excel Worksheet.
In this worksheet, there is a list of accounts. However, in this unordered
list, are pairs of each account with three extra characters on the end. eg:
100001/1000001
100001/1000002
100001/1000004
100002/2000002
100001/1000001DMA
100002/2000002DMA

I would like to create a macro that checks the first 14 characters from the
left of the values in Column A, and groups each pair together as well as
leaving a line between each set.

Please could someone provide me with some advice for this issue? I really
would appreciate it.

Regards,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Sorting a Worksheet by the first 14 characters in Column A

Option Explicit
Sub Main()
Dim lastrow As Long
Dim rw As Long
With Range("A:A")
.Sort .Range("A1")
lastrow = .Range("A1").End(xlDown).Row
End With
For rw = lastrow To 2 Step -1
If Left(Cells(rw, 1).Value, 14) < Left(Cells(rw - 1, 1).Value, 14) Then
Rows(rw).Insert
End If
Next
End Sub

"PVANS" wrote:

Good morning

Currently, each day I am required to sort and "clean" an Excel Worksheet.
In this worksheet, there is a list of accounts. However, in this unordered
list, are pairs of each account with three extra characters on the end. eg:
100001/1000001
100001/1000002
100001/1000004
100002/2000002
100001/1000001DMA
100002/2000002DMA

I would like to create a macro that checks the first 14 characters from the
left of the values in Column A, and groups each pair together as well as
leaving a line between each set.

Please could someone provide me with some advice for this issue? I really
would appreciate it.

Regards,

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
Sorting on only certain characters in a cell Lesa Excel Worksheet Functions 3 November 25th 08 07:32 PM
Sorting a worksheet with embedded documents in one column JHQ Excel Discussion (Misc queries) 2 October 21st 08 05:45 PM
Ignoring characters when sorting amy153 Excel Discussion (Misc queries) 0 February 14th 06 09:20 PM
Sorting a 2 column list with VBA using Worksheet change produces 1004 error Casey[_10_] Excel Programming 3 June 28th 04 04:38 PM
Sorting a column in a different worksheet Ric Payne Excel Programming 1 September 25th 03 11:37 PM


All times are GMT +1. The time now is 07:27 AM.

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"