Results 1 to 2 of 2

Sorting all data based on data in single column (DATES)

Threaded View

subbby Sorting all data based on... 10-15-2013, 03:52 PM
subbby Re: Sorting all data based on... 10-16-2013, 08:19 AM
  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Sorting all data based on data in single column (DATES)

    Have this excel sheet and I need to sort all columns based of on data in Column H
    • Column H are dates
    • Ask the user to select the range
    • Once selected, sort all data based on the values in column H in newest to oldest

    I tried the following :


    Sub qwerty()
    
    
    
        Dim r As Range
        Dim v As String
        Dim x As String
        
        
    
     Set r = Application.InputBox(Prompt:="Please Select Range", Title:="Range Select", Type:=8)
     r.Select
     
    
        ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=r _
            , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
           
             Dim rr As Range
            rr = Range("I2").End(xlDown)
    '           ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("I2:I100") _
            , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("Sheet1").Sort
      
            
            
            
            
            .SetRange Range("A2:I2.End(xlDown)")
            
            
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    
    End Sub

    Problem I encountered:
    • Unable to select all the rows and columns – I think I am unable to tell it which is the LAST ROW that needs to be selected


    Another thing I tried doing is:
    • Record the macro and go to DATA>Sort and select the columns and sort them from newest to oldest.



    This gives the output but :
    • It sorts row 1 too
    • The selection has to be a user input using input box

    FILE ATTACHED:

    Thanks,





    xlmxm.xlsm
    Last edited by subbby; 10-15-2013 at 04:11 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sorting Data to New Worksheet Based off of Entry in Column A
    By dirtdoctor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 12:03 PM
  2. [SOLVED] Sorting data into multiple columns based on a single column
    By J.McQ in forum Excel General
    Replies: 7
    Last Post: 03-16-2013, 11:26 AM
  3. [SOLVED] Sorting rows of data based off a single column for a variable number of entries.
    By soxcrates in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2012, 12:31 PM
  4. Sorting Rows Based on a Column Data
    By amtrane in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-21-2007, 05:47 PM
  5. Replies: 1
    Last Post: 07-25-2006, 05:29 AM

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