Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sorting on only certain characters in a cell | Excel Worksheet Functions | |||
Sorting a worksheet with embedded documents in one column | Excel Discussion (Misc queries) | |||
Ignoring characters when sorting | Excel Discussion (Misc queries) | |||
Sorting a 2 column list with VBA using Worksheet change produces 1004 error | Excel Programming | |||
Sorting a column in a different worksheet | Excel Programming |