+ Reply to Thread
Results 1 to 21 of 21

sort and then insert rows help!

Hybrid View

  1. #1
    Dave Peterson
    Guest

    Re: sort and then insert rows help!

    It's a nice benefit. Take advantage of it while it's still there.

    RompStar wrote:
    >
    > yep, yep, I was just waiting for you to help me, lol
    >
    > I have learnd so much from you already :- ) taking advantage of a
    > education
    > reimbursement program here at work, so I started to go to college for
    > database administration, hopefully I will learn a lot more in the next
    > 3-4 years :- )
    >
    > Thanks a lot!


    --

    Dave Peterson

  2. #2
    RompStar
    Guest

    Re: sort and then insert rows help!

    so I commented out the insert row part of the vb code and only wanted
    to see if the sorting works,
    it sorts, but not correctly, it sorts the same name maybe 5 rows and
    then it goes to the next,
    and then it eventually starts to sort the same name again, it doens't
    sort them all
    in one shot and then go to the next, the sort is kinda broken apart
    sort, not even all the way through ?

    any ideas why ?


  3. #3
    Dave Peterson
    Guest

    Re: sort and then insert rows help!

    Record a macro when you sort by both keys.

    Then modify this portion:

    .Columns("A:F").Sort _
    Key1:=.Range("A1"), Order1:=xlAscending, _
    Key2:=.Range("B1"), Order2:=xlAscending, _
    Header:=xlNo, OrderCustom:=1, MatchCase:=False, _
    Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

    Maybe it's just swapping key1 and key2?????

    RompStar wrote:
    >
    > so I commented out the insert row part of the vb code and only wanted
    > to see if the sorting works,
    > it sorts, but not correctly, it sorts the same name maybe 5 rows and
    > then it goes to the next,
    > and then it eventually starts to sort the same name again, it doens't
    > sort them all
    > in one shot and then go to the next, the sort is kinda broken apart
    > sort, not even all the way through ?
    >
    > any ideas why ?


    --

    Dave Peterson

  4. #4
    RompStar
    Guest

    Re: sort and then insert rows help!

    Macro 2 works, Macro 3 don't work, I noticed that when I sort by Column
    A and then I repeat the sort process by column B, it works,
    but if I try to sort A and B at the same time, it don't.



    Sub Macro2()
    '
    ' Macro2 Macro
    '

    '
    Columns("A:F").Select
    Range("F1").Activate
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
    Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal


    Selection.Sort Key1:=Range("B1"), Order1:=xlAscending,
    Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    End Sub
    Sub Macro3()
    '
    ' Macro3 Macro

    '
    Columns("A:F").Select
    Range("F1").Activate
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
    Key2:=Range("B1") _
    , Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
    MatchCase:=False, _
    Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
    DataOption2:= _
    xlSortNormal
    Range("E25").Select
    End Sub


  5. #5
    Dave Peterson
    Guest

    Re: sort and then insert rows help!

    I meant try this:

    .Columns("A:F").Sort _
    Key1:=.Range("B1"), Order1:=xlAscending, _
    Key2:=.Range("A1"), Order2:=xlAscending, _
    Header:=xlNo, OrderCustom:=1, MatchCase:=False, _
    Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

    So Column B becomes the primary sort and column A is the secondary sort.



    RompStar wrote:
    >
    > Macro 2 works, Macro 3 don't work, I noticed that when I sort by Column
    > A and then I repeat the sort process by column B, it works,
    > but if I try to sort A and B at the same time, it don't.
    >
    > Sub Macro2()
    > '
    > ' Macro2 Macro
    > '
    >
    > '
    > Columns("A:F").Select
    > Range("F1").Activate
    > Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
    > Header:=xlGuess, _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal
    >
    > Selection.Sort Key1:=Range("B1"), Order1:=xlAscending,
    > Header:=xlGuess, _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal
    > End Sub
    > Sub Macro3()
    > '
    > ' Macro3 Macro
    >
    > '
    > Columns("A:F").Select
    > Range("F1").Activate
    > Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
    > Key2:=Range("B1") _
    > , Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
    > MatchCase:=False, _
    > Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
    > DataOption2:= _
    > xlSortNormal
    > Range("E25").Select
    > End Sub


    --

    Dave Peterson

  6. #6
    RompStar
    Guest

    Re: sort and then insert rows help!

    ohhhh :-) let me try that...


  7. #7
    RompStar
    Guest

    Re: sort and then insert rows help!

    yep it worked...

    Ok another question :- )

    Now that I have my columns seperated by the employee name in column B
    or 2, with a 25 space row insert, like in this example
    I have 6 employees that I am doing a productivity report on, so there
    is 6, 25 space inserts..

    Now on each employees data block I guess you call it, I want to select
    those blocks and sort them by the activity type which is
    in column C or 3. My manual step was to highlight the effected block
    of data and then sort it by column C with no headers, then
    move down 25 space, and select manually the next block of data and sort
    again my column C with no headers.

    The 25 space is needed, because later I insert a template in there that
    sums up all the numbers and presents in
    into a manager view, but that's the last step, I will be happy to
    automate the majority of it :- ) and I learn a lot
    along the way.

    See it's impossible to select columns A - F and then sort by C, because
    of the 25 spaces it dones't sort it right, there is no way to
    tell it to ignore the empty spaces, so I have to find the first set of
    data, highlight it and sort it and so on..

    This is a good one to learn I'll bet...

    :- )


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1