+ Reply to Thread
Results 1 to 6 of 6

Looping thru columns

  1. #1
    Robert
    Guest

    Looping thru columns

    Seek assistance to convert the following macro code to loop the sorting from
    col c thru col IV.
    Range("A1:IR2000").Select
    Selection.Copy
    Application.Goto Reference:="R11000C1"
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False
    Range("C11001:C12999").Select
    Application.CutCopyMode = False
    Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending, Header:=xlNo, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    Range("D11001:D12999").Select
    Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending, Header:=xlNo, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    End Sub

    Thank you.
    RobertR

  2. #2
    Bob Phillips
    Guest

    Re: Looping thru columns

    Not tested

    Dim i As Long
    Range("A1:IR2000").Copy
    Range("A11000").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False
    For i = 3 To 256
    Application.CutCopyMode = False
    Cells(11001, i).Resize(1999).Sort Key1:=Range("C11001"), _
    Order1:=xlAscending, _
    Header:=xlNo, _
    OrderCustom:=1, _
    MatchCase:=False, _
    Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    Next i


    --
    HTH

    Bob Phillips

    "Robert" <[email protected]> wrote in message
    news:[email protected]...
    > Seek assistance to convert the following macro code to loop the sorting

    from
    > col c thru col IV.
    > Range("A1:IR2000").Select
    > Selection.Copy
    > Application.Goto Reference:="R11000C1"
    > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    > Range("C11001:C12999").Select
    > Application.CutCopyMode = False
    > Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending,

    Header:=xlNo, _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal
    > Range("D11001:D12999").Select
    > Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending,

    Header:=xlNo, _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal
    > End Sub
    >
    > Thank you.
    > RobertR




  3. #3
    Robert
    Guest

    Re: Looping thru columns

    Bob thanks for the speedy response. I get the following error msg.
    "Run time error 1004

    The Sort reference is not valid. Make sure that its within the
    data you want to sort....."

    Also do I end with "End Sub". Thanks.
    --
    Robert


    "Bob Phillips" wrote:

    > Not tested
    >
    > Dim i As Long
    > Range("A1:IR2000").Copy
    > Range("A11000").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    > For i = 3 To 256
    > Application.CutCopyMode = False
    > Cells(11001, i).Resize(1999).Sort Key1:=Range("C11001"), _
    > Order1:=xlAscending, _
    > Header:=xlNo, _
    > OrderCustom:=1, _
    > MatchCase:=False, _
    > Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal
    > Next i
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Robert" <[email protected]> wrote in message
    > news:[email protected]...
    > > Seek assistance to convert the following macro code to loop the sorting

    > from
    > > col c thru col IV.
    > > Range("A1:IR2000").Select
    > > Selection.Copy
    > > Application.Goto Reference:="R11000C1"
    > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > SkipBlanks _
    > > :=False, Transpose:=False
    > > Range("C11001:C12999").Select
    > > Application.CutCopyMode = False
    > > Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending,

    > Header:=xlNo, _
    > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > > DataOption1:=xlSortNormal
    > > Range("D11001:D12999").Select
    > > Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending,

    > Header:=xlNo, _
    > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    > > DataOption1:=xlSortNormal
    > > End Sub
    > >
    > > Thank you.
    > > RobertR

    >
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: Looping thru columns

    Sorry my mistake

    Dim i As Long
    Range("A1:IR2000").Copy
    Range("A11000").PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, _
    SkipBlanks:=False, _
    Transpose:=False
    For i = 3 To 256
    Application.CutCopyMode = False
    Cells(11001, i).Resize(1999).Sort Key1:=Cells(11001,i), _
    Order1:=xlAscending, _
    Header:=xlNo, _
    OrderCustom:=1, _
    MatchCase:=False, _
    Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    Next i


    --
    HTH

    Bob Phillips

    "Robert" <[email protected]> wrote in message
    news:[email protected]...
    > Bob thanks for the speedy response. I get the following error msg.
    > "Run time error 1004
    >
    > The Sort reference is not valid. Make sure that its within the
    > data you want to sort....."
    >
    > Also do I end with "End Sub". Thanks.
    > --
    > Robert
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Not tested
    > >
    > > Dim i As Long
    > > Range("A1:IR2000").Copy
    > > Range("A11000").PasteSpecial Paste:=xlPasteValues,

    Operation:=xlNone,
    > > SkipBlanks _
    > > :=False, Transpose:=False
    > > For i = 3 To 256
    > > Application.CutCopyMode = False
    > > Cells(11001, i).Resize(1999).Sort Key1:=Range("C11001"), _
    > > Order1:=xlAscending, _
    > > Header:=xlNo, _
    > > OrderCustom:=1, _
    > > MatchCase:=False, _
    > > Orientation:=xlTopToBottom, _
    > > DataOption1:=xlSortNormal
    > > Next i
    > >
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "Robert" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Seek assistance to convert the following macro code to loop the

    sorting
    > > from
    > > > col c thru col IV.
    > > > Range("A1:IR2000").Select
    > > > Selection.Copy
    > > > Application.Goto Reference:="R11000C1"
    > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > SkipBlanks _
    > > > :=False, Transpose:=False
    > > > Range("C11001:C12999").Select
    > > > Application.CutCopyMode = False
    > > > Selection.Sort Key1:=Range("C11001"), Order1:=xlAscending,

    > > Header:=xlNo, _
    > > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,

    _
    > > > DataOption1:=xlSortNormal
    > > > Range("D11001:D12999").Select
    > > > Selection.Sort Key1:=Range("D11001"), Order1:=xlAscending,

    > > Header:=xlNo, _
    > > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,

    _
    > > > DataOption1:=xlSortNormal
    > > > End Sub
    > > >
    > > > Thank you.
    > > > RobertR

    > >
    > >
    > >




  5. #5
    Robert
    Guest

    Re: Looping thru columns

    Bob, a BIG thank you for your help. My application runs in a jiffy compared to
    using formulas for autosort which took ages.
    --
    RobertR




  6. #6
    Bob Phillips
    Guest

    Re: Looping thru columns

    You're welcome Robert. Always nice to get a result <G>

    Bob

    "Robert" <[email protected]> wrote in message
    news:[email protected]...
    > Bob, a BIG thank you for your help. My application runs in a jiffy

    compared to
    > using formulas for autosort which took ages.
    > --
    > RobertR
    >
    >
    >




+ 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