Author Topic: Excel sorting conundrum  (Read 1931 times)

Offline Fkacn_tt

  • Global Moderator
  • Kage
  • *
  • Posts: 1500
  • Country: 00
  • Chakra 2
    • PS3,PsP, Dead PS2
  • Referrals: 1
    • View Profile
  • CPU: AMD Athlon 64 X2 4400+
  • GPU: XFX 4850 512mb
  • RAM: 2 GB PC 6400
  • Broadband: Flow
  • PSN: r_guy007
Excel sorting conundrum
« on: July 08, 2010, 03:53:04 PM »
I am trying to sort 2 adjacent columns with data in this order:

item2   item2sub1
            item2sub3
            item2sub2
            item2sub4
item1   item1sub3
            item1sub1
            item1sub2
item3   item3sub4
            item3sub2
            item3sub1
            item3sub3

whenever i sort this menu it keeps messing up the order between the item# and its corresponding item#sub#.

any help would be greatly appreciated in sorting this data.
P.S. the actual data is alphabetical and would be sorted alphabetically in ascending order.

EG.

item1   item1sub1
            item1sub2
            item1sub3
            item1sub4
item2   item2sub1
            item2sub2
            item2sub3
item3   item3sub1
            item3sub2
            item3sub3
            item3sub4

the item#sub# sorting is not a priority just the item# anything extra would be welcomed.
« Last Edit: July 08, 2010, 03:58:42 PM by Slaming »
" border="0

Carigamers

Excel sorting conundrum
« on: July 08, 2010, 03:53:04 PM »

Offline phoenix31tt

  • Kage
  • ****
  • Posts: 1546
  • Country: 00
  • Chakra -2
    • PS3
  • Referrals: 1
    • View Profile
  • CPU: Intel i7 920 @ 4.0Ghz
  • GPU: Sapphire 5970
  • RAM: 12GB OCZ Reaper 1800Mhz
  • Broadband: Flow
  • PSN: phoenix_31tt
  • XBL: phoenix31tt
Re: Excel sorting conundrum
« Reply #1 on: July 08, 2010, 05:32:49 PM »
in excel you would have to enable macros and write a vba script to do something like that...

it can be done of the bat with something like access doh...

how important is this to you? cuz u could also just do it the long way and manually sort the first column then sort the second column by selecting the different groups

Offline Fkacn_tt

  • Global Moderator
  • Kage
  • *
  • Posts: 1500
  • Country: 00
  • Chakra 2
    • PS3,PsP, Dead PS2
  • Referrals: 1
    • View Profile
  • CPU: AMD Athlon 64 X2 4400+
  • GPU: XFX 4850 512mb
  • RAM: 2 GB PC 6400
  • Broadband: Flow
  • PSN: r_guy007
Re: Excel sorting conundrum
« Reply #2 on: July 09, 2010, 11:01:39 AM »
ill try the macros way it that dose not work, ill try the manual method.
" border="0

Offline phoenix31tt

  • Kage
  • ****
  • Posts: 1546
  • Country: 00
  • Chakra -2
    • PS3
  • Referrals: 1
    • View Profile
  • CPU: Intel i7 920 @ 4.0Ghz
  • GPU: Sapphire 5970
  • RAM: 12GB OCZ Reaper 1800Mhz
  • Broadband: Flow
  • PSN: phoenix_31tt
  • XBL: phoenix31tt
Re: Excel sorting conundrum
« Reply #3 on: July 09, 2010, 01:10:50 PM »
If you familiar with VBA coding i found the following script which may help.. you would need to modify it however

It needs a sheet called "temp", and requires that every section be spaced by iRowsPerJob rows (see code).

Code: [Select]
Sub SortJobs()
    Dim iR As Integer, jR As Integer
    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim sFirstAdrs As String
    Dim rFound As Range
    Dim rCopy As Range
    Dim nJobs As Long
    Const iRowsPerJob As Integer = 13
       
    Set ws1 = ThisWorkbook.Worksheets(1)
    Set ws2 = ThisWorkbook.Sheets("temp")
    ws2.Cells.Clear
   
    ' copy the job numbers to "temp"
    With ws1.Range("A:A")
        Set rFound = .Find( _
What:="Job #:", _
                           After:=ws1.Range("a1"), _
                           LookIn:=xlValues)
        sFirstAdrs = rFound.Address
        Do
            jR = jR + 1
            ws2.Cells(jR, 1) = rFound.Offset(, 1) ' job #
            Set rFound = .FindNext(rFound)
        Loop While Not rFound Is Nothing And rFound.Address <> sFirstAdrs
    End With
   
    ' sort by job number
    ws2.UsedRange.Sort Key1:=ws2.Cells(1, 1), Order1:=xlAscending, _
                       Orientation:=xlSortColumns, Header:=xlNo
   
    ' cut the jobs in order to the bottom of the list
    Application.EnableEvents = False
   
    nJobs = ws2.Cells(Rows.Count, 1).End(xlUp).Row
    Set rCopy = ws1.Range(sFirstAdrs).Offset(iRowsPerJob * nJobs)
   
    For iR = 1 To nJobs
        ' the two-column range is necessary because of the merged cells
        Set rFound = ws1.Range("B:C").Find( _
What:=ws2.Cells(iR, 1), _
                                           LookIn:=xlFormulas, _
                                           After:=ws1.Range("B1"))
        ws1.Cells(rFound.Row, 1).Resize(iRowsPerJob).EntireRow.Cut
        rCopy.Insert shift:=xlDown
    Next
    Application.EnableEvents = True
                       
End Sub

Gluck

Carigamers

Re: Excel sorting conundrum
« Reply #3 on: July 09, 2010, 01:10:50 PM »

 


* ShoutBox

Refresh History
  • Crimson609: yea everything cool how are you?
    August 10, 2022, 07:26:15 AM
  • Pain_Killer: Good day, what's going on with you guys? Is everything Ok?
    February 21, 2021, 05:30:10 PM
  • Crimson609: BOOM covid-19
    August 15, 2020, 01:07:30 PM
  • Shinsoo: bwda 2020 shoutboxing. omg we are in the future and in the past at the same time!
    March 03, 2020, 06:42:47 AM
  • TriniXjin: Watch Black Clover Everyone!
    February 01, 2020, 06:30:00 PM
  • Crimson609: lol
    February 01, 2020, 05:05:53 PM
  • Skitz: So fellas how we go include listing for all dem parts for pc on we profile but doh have any place for motherboard?
    January 24, 2020, 09:11:33 PM
  • Crimson609: :ph34r:
    January 20, 2019, 09:23:28 PM
  • Crimson609: Big up ya whole slef
    January 20, 2019, 09:23:17 PM
  • protomanex: Gyul like Link
    January 20, 2019, 09:23:14 PM
  • protomanex: Man like Kitana
    January 20, 2019, 09:22:39 PM
  • protomanex: Man like Chappy
    January 20, 2019, 09:21:53 PM
  • protomanex: Gyul Like Minato
    January 20, 2019, 09:21:48 PM
  • protomanex: Gyul like XJin
    January 20, 2019, 09:19:53 PM
  • protomanex: Shout out to man like Crimson
    January 20, 2019, 09:19:44 PM
  • Crimson609: shout out to gyal like Corbie Gonta
    January 20, 2019, 09:19:06 PM
  • cold_187: Why allur don't make a discord or something?
    December 03, 2018, 06:17:38 PM
  • Red Paradox: https://www.twitch.tv/flippay1985 everyday from 6:00pm
    May 29, 2018, 09:40:09 AM
  • Red Paradox: anyone play EA Sports UFC 3.. Looking for a challenge. PSN: Flippay1985 :)
    May 09, 2018, 11:00:52 PM
  • cold_187: @TriniXjin not really, I may have something they need (ssd/ram/mb etc.), hence why I also said "trade" ;)
    February 05, 2018, 10:22:14 AM

SimplePortal 2.3.3 © 2008-2010, SimplePortal