Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Help! VBA code to sort records where a record exists on two consecutiv rows. There are no blank rows between records & the 1st record start on line 2. For Example: Row 2: Doe John 123 South Street Summerville, TX 76625 Row 3: (903)752-4813 Row 4: Johnson Jack 1849 Hwy 200 Johnsonville, TX 76362 Row 5: (903)238-5849 The number of records to sort are always different since when record are added, they will be sorted in. Usually we will be sorting usin column A & maybe column B. Thanks for any & all help. mikebur -- mikebur ----------------------------------------------------------------------- mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458 View this thread: http://www.excelforum.com/showthread.php?threadid=46688 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike,
Try the macro below. HTH, Bernie MS Excel MVP Sub Macro1() Dim myRow As Long Columns("A:B").Insert Range("A1").Value = "Sort1" Range("B1").Value = "Sort2" Range("A2").FormulaR1C1 = "=RC[2]" Range("A3").FormulaR1C1 = "=R[-1]C[2]" Range("A2:A3").Copy myRow = Cells(Rows.Count, 3).End(xlUp).Row If myRow Mod 2 < 1 Then myRow = myRow + 1 Range("A2:B" & myRow).Select ActiveSheet.Paste With Columns("A:B") .Copy .PasteSpecial Paste:=xlPasteValues End With Range("A3").CurrentRegion.Sort Key1:=Range("A2"), Order1:=xlAscending, _ Key2:=Range("B2"), Order2:=xlAscending, Header:=xlYes, _ Orientation:=xlTopToBottom, DataOption1:=xlSortNormal Columns("A:B").Delete End Sub "mikeburg" wrote in message ... Help! VBA code to sort records where a record exists on two consecutive rows. There are no blank rows between records & the 1st record starts on line 2. For Example: Row 2: Doe John 123 South Street Summerville, TX 76625 Row 3: (903)752-4813 Row 4: Johnson Jack 1849 Hwy 200 Johnsonville, TX 76362 Row 5: (903)238-5849 The number of records to sort are always different since when records are added, they will be sorted in. Usually we will be sorting using column A & maybe column B. Thanks for any & all help. mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581 View this thread: http://www.excelforum.com/showthread...hreadid=466882 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thank you. mikebur -- mikebur ----------------------------------------------------------------------- mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458 View this thread: http://www.excelforum.com/showthread.php?threadid=46688 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Group/Sort records in Excel | Excel Discussion (Misc queries) | |||
sort name records according to criteria | Excel Discussion (Misc queries) | |||
When i sort records...Only from Colomn A to O does it sort the lis | Excel Discussion (Misc queries) | |||
How do I sort records that are on two lines in a spreadsheet? | Excel Worksheet Functions | |||
How to sort/synchronise 2 data columns with missing records? | Excel Discussion (Misc queries) |