+ Reply to Thread
Results 1 to 7 of 7

VBA range and selection

  1. #1
    Registered User
    Join Date
    06-26-2017
    Location
    Colorado
    MS-Off Ver
    2017 and 2013
    Posts
    7

    VBA range and selection

    Using the Sort ability of Excel I would like to plug in the Active Cells into the Range rather than a hardcoded number or cell

    So instead of
    Please Login or Register  to view this content.
    I would like the ranges to be the active selection

    Like ActiveWorkbook.Worksheets("Schedule").Sort.SortFields.Add Key:=Range("SELECTION"), SortOn:=xlSortOnValues, Order:=xlAscending,

    If this is unclear then you can look at all my code below (Yes Segment 1 works but I needs to be rewritten also to account for added rows)

    Please Login or Register  to view this content.
    Last edited by 817279; 06-26-2017 at 06:25 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: VBA range and selection

    Use Selection and not Range("SELECTION")

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA range and selection

    perhaps
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    06-26-2017
    Location
    Colorado
    MS-Off Ver
    2017 and 2013
    Posts
    7

    Re: VBA range and selection

    Didnt work... Any other ideas?

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA range and selection

    "Didn't work" is rather vague.

    Could you attach a workbook showing a (small) initial set up and the display you want after the macro is run?

  6. #6
    Registered User
    Join Date
    06-26-2017
    Location
    Colorado
    MS-Off Ver
    2017 and 2013
    Posts
    7

    Re: VBA range and selection

    I used record macro to figure out how to make vba sort but it wont let the range be the selected area. This will be a problem when the user adds or removes rows so I need vba to sort values in a range given that the number of rows could change

    Column AI is a Match function that finds the first date that work begins and then sorting that column makes the whole chart flow
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by 817279; 06-28-2017 at 05:53 PM.

  7. #7
    Registered User
    Join Date
    06-26-2017
    Location
    Colorado
    MS-Off Ver
    2017 and 2013
    Posts
    7

    Re: VBA range and selection

    So... any ideas?

+ 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. [SOLVED] Error 1004 Method range of object when trying to clear range selection
    By shoulddt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2017, 10:09 PM
  2. Copy specific range selection to msword but why it copies columns not in range?
    By adbasanta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2016, 03:46 AM
  3. Replies: 0
    Last Post: 12-10-2014, 11:30 AM
  4. [SOLVED] I need help range selection and cells selection
    By venkatpvc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2013, 07:36 PM
  5. [SOLVED] Range(Selection, Selection.End(xlDown)).Select goes to 65536 instead of last filled row
    By looney in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-12-2013, 10:51 AM
  6. Replies: 2
    Last Post: 04-20-2012, 12:23 PM
  7. Hide rows in range 2 based on filter selection in range 1
    By gtol in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-28-2012, 02:09 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