+ Reply to Thread
Results 1 to 3 of 3

Copy Range from one sheet to another and sort

  1. #1
    Registered User
    Join Date
    02-06-2019
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    5

    Copy Range from one sheet to another and sort

    Good day to you all,

    I'm sure this is a simple task, and I've tried, but can't seem to find the magic formula. I've searched this forum for something similar and the internet but I am unable to find what I want. I can do it in Google Sheets, but I can't seem to get it to work in Excel 2016.

    I want to grab a range from one sheet, and have it show up on another sheet, sorted with either no blanks or the blanks sorted to the bottom of the range.

    This is my google formula:
    =FILTER(INPUT!D2:D14,ISBLANK(INPUT!D2:D14)=FALSE)

    Thanks for any help, and have a wonderful day.

  2. #2
    Registered User
    Join Date
    02-06-2019
    Location
    Bangalore, India
    MS-Off Ver
    MS Office 2013
    Posts
    9

    Re: Copy Range from one sheet to another and sort

    Below is the code for the task you had given:

    NB: This is considering that there is a sheet named Sheet2(where you want the range to be sorted with blanks at the bottom). And your input is on the page named "Input"

    ------------------------------------------------------------------------------------

    Sub RangeSort()
    '
    ' RangeSort Macro
    '
    Sheets("Sheet2").Select
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "=IF(Input!RC[3]="""","""",VALUE(Input!RC[3]))"
    Range("A2:A14").Select
    Selection.FillDown
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Add Key:=Range("A2:A14") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet2").Sort
    .SetRange Range("A2:A14")
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    End Sub

  3. #3
    Registered User
    Join Date
    02-06-2019
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    5

    Re: Copy Range from one sheet to another and sort

    I tried to get this to work, by putting the script activation on the "Shadow List" column, beginning in Cell E1. It failed as it started with a Blank Cell. If possible, I'd also like this to be an active script not having to be launched via Alt+F8. (I'm trying to make this Sheet Supervisor Proof)

    My end request for this to work correctly, is depending on Staffing I have for the day, they are manually typed into Column A, A2:A14. If only 10 employee's show up, then there will be 3 blanks on the bottom (not an issue). I have trainee's (Shadows) show up from time to time to have O.J.T. with a seasoned employee, as assigned in the Shadow Staff Column C on the same row as as the assigned Trainer. Then I'd like to have the Shadow Staff copied and sorted in Column E under the Shadow List A2:A14 with blanks removed as show in the attached image. Lastly, I'd like to have the end result in Column A, A17:A29, with the Staff combined as shown.

    I got all of this to work on Google Sheets, but am trying to learn Excel as well.

    Again, I appreciate the above VB Script, I just don't know how to edit it beyond the obvious variable.

    Thank you again, and much appreciated.

    Excel_1.png

+ 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. VBA/Macro to Automatically Update, Copy, & Sort information from Sheet 1 to Sheet 2
    By E9demello in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-10-2017, 09:37 AM
  2. [SOLVED] vba code to sort data in two sheets and copy and paste sort data in output sheet
    By UPA in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2017, 05:13 AM
  3. Replies: 0
    Last Post: 03-01-2015, 01:56 PM
  4. Copy and sort data from a master sheet to a copy
    By ima_ms in forum Excel General
    Replies: 0
    Last Post: 02-26-2015, 08:35 AM
  5. Replies: 1
    Last Post: 06-05-2013, 07:03 AM
  6. Replies: 2
    Last Post: 05-09-2013, 10:15 PM
  7. Macro to Look for Sheet, create if none, sort items from master & copy to new sheet.
    By ali.whitaker in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-25-2012, 12:58 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