+ Reply to Thread
Results 1 to 2 of 2

Expanding the selection range

  1. #1
    Registered User
    Join Date
    07-23-2013
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    1

    Exclamation Expanding the selection range

    Hello everyone,

    I am currently trying to create a marco that would sort the amounts in a data list from largest to smallest. My problem is this that while recording the macro, I selected a set range and now I cannot get it to expand that selection. I am not sure what to do. Below is what it currently looks like and I want to customise it so it can sort the data no matter how big the range. Please help!

    Many thanks
    Priyanka.
    Sub Test()
    '
    ' Test Macro
    ' Sorts amount
    '

    '
    Range("A1:D8").Select
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("B2:B8"), _
    SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
    .SetRange Range("A1:D8")
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    Range("C10").Select

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Expanding the selection range

    To help facilitate learning i'll keep most of you recorded macro the same:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. For each cell in range loop does not recognize expanding range
    By jhren in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-07-2013, 07:49 AM
  2. Expanding Selection
    By aposatsk in forum Excel General
    Replies: 3
    Last Post: 08-16-2006, 12:25 PM
  3. [SOLVED] Expanding a Selection
    By Shorty in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-05-2006, 11:10 AM
  4. expanding a range of numbers
    By chchch in forum Excel General
    Replies: 1
    Last Post: 02-28-2006, 03:55 PM
  5. [SOLVED] sorting data and expanding the selection
    By Barnet1 in forum Excel General
    Replies: 2
    Last Post: 01-23-2006, 09:55 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