Results 1 to 3 of 3

Sorting 10 rows without affecting other rows

Threaded View

peterkin Sorting 10 rows without... 03-23-2021, 12:13 AM
AliGW Re: Sorting 10 rows without... 03-23-2021, 02:02 AM
peterkin Re: Sorting 10 rows without... 03-23-2021, 02:18 AM
  1. #1
    Registered User
    Join Date
    03-23-2021
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    2

    Question Sorting 10 rows without affecting other rows

    Hi all, I have a question when using sorting function in VBA.

    I have a table which have around 30 rows.
    I would like to sort the date of 10 rows within the table (say row 11-20 only) and do not want to affect other rows.

    I created the following commend in VBA but fail to do so.

    Sub Test()
    
        With ActiveSheet.Sort.SortFields
            .Clear
            .Add Columns(3), Order:=xlAscending
            .Add Columns(2), Order:=xlDescending
            .Add Columns(1), Order:=xlAscending
        End With
        
        With ActiveSheet.Sort
            .SetRange ActiveCell
            .Header = xlNo
            .MatchCase = False
            .Apply
        End With
     
    End Sub
    I selected rows 11-20 but it sorted the whole table.
    How can I fix it?

    Thank you
    Kin
    Last edited by AliGW; 03-23-2021 at 02:01 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] 3-level sorting including sorting a column by the number of percent sign in each cell
    By terryhenderson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2017, 05:21 PM
  2. Replies: 1
    Last Post: 12-16-2015, 01:04 PM
  3. [SOLVED] I require sorting formula in excel sheet with complex sorting.
    By kaminanirav in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-24-2015, 08:16 AM
  4. Replies: 0
    Last Post: 02-24-2014, 11:27 AM
  5. Sorting 2 data ranges by comparing one column in each and sorting to match
    By MDKsmiffy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-17-2013, 03:30 PM
  6. Sorting a range to invert it upside down without sorting by any specific column
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2013, 12:53 PM
  7. [SOLVED] Sorting a range to invert it upside down without sorting by any specific column
    By luv2glyd in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-28-2013, 12:43 PM

Tags for this Thread

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