Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA sort records occupying 2 rows each


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default VBA sort records occupying 2 rows each

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA sort records occupying 2 rows each


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
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
Group/Sort records in Excel Curious[_2_] Excel Discussion (Misc queries) 3 April 22nd 09 11:35 PM
sort name records according to criteria -keevill- Excel Discussion (Misc queries) 3 July 20th 08 02:02 PM
When i sort records...Only from Colomn A to O does it sort the lis Randall Excel Discussion (Misc queries) 1 October 26th 06 01:19 AM
How do I sort records that are on two lines in a spreadsheet? ecox Excel Worksheet Functions 2 August 22nd 06 08:43 PM
How to sort/synchronise 2 data columns with missing records? Rik Excel Discussion (Misc queries) 3 February 24th 06 10:24 PM


All times are GMT +1. The time now is 05:47 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"