Results 1 to 7 of 7

Code for selection of range by user

Threaded View

  1. #1
    Registered User
    Join Date
    01-16-2018
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    3

    Code for selection of range by user

    Hi,

    I have following Code in a macro

    Sub SORT()
    '
    ' SORT Macro
    ' SORT BY MONTH
    '
    
    '
        Rows("47:61").Select
        ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT.SortFields.Clear
        ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT.SortFields.Add _
            Key:=Range("H47:H61"), SortOn:=xlSortOnValues, Order:=xlDescending, _
            DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT.SortFields.Add _
            Key:=Range("I47:I61"), SortOn:=xlSortOnValues, Order:=xlDescending, _
            DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT.SortFields.Add _
            Key:=Range("J47:J61"), SortOn:=xlSortOnValues, Order:=xlDescending, _
            DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT.SortFields.Add _
            Key:=Range("L47:L61"), SortOn:=xlSortOnValues, Order:=xlDescending, _
            DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT.SortFields.Add _
            Key:=Range("M47:M61"), SortOn:=xlSortOnValues, Order:=xlDescending, _
            DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT.SortFields.Add _
            Key:=Range("N47:N61"), SortOn:=xlSortOnValues, Order:=xlDescending, _
            DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets(" Forecast by Region >$100k").SORT
            .SetRange Rows("47:61")
            .Header = xlGuess
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End Sub
    In this currently the sort range and each collumn range is fixed but I would like to replace it by a user selectable range. What code I should insert.

    thanks
    Last edited by sacash; 01-16-2018 at 02:47 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Dynamic Range, based on user selection, used with FOR LOOP
    By ericbartha in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2015, 05:08 PM
  2. Replies: 0
    Last Post: 12-10-2014, 11:30 AM
  3. Long range calendar with changing color based on user selection
    By jrholden in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-31-2013, 04:51 PM
  4. Issue with range selection within user form
    By AndrewWheeler87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2013, 03:05 PM
  5. Looking to code combo/drop down list user selection and display formula results
    By toddbailey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2012, 06:17 PM
  6. Error on code to copy and paste user selection.
    By leaning in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2011, 10:52 AM
  7. With Selection Input Cell Value or Range into User Form
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2010, 05:36 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