+ Reply to Thread
Results 1 to 1 of 1

Sorting by alternate values, then copy next row's cell, past to current row, delete row.

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    Vancouver
    MS-Off Ver
    Office 2013
    Posts
    1

    Sorting by alternate values, then copy next row's cell, past to current row, delete row.

    Hi,

    I have attached the xls file I'm working on to make it easier for you to understand.

    First thing is I want to filter data to only blank cells on C ("2nd Name"). Simple enough.

    Then, the first level sort is I want to sort ascending on D ("Preference), 2nd level sort ascending on E ("Novice/Pro") Simple enough.

    Here's the difficult part.

    I want to check if the first row is a novice or pro, if novice, go down the row and find a pro. Copy the name of the pro and add to the 2nd name column (at C) and then delete the entire row of the pro. If no pro can be found, search for a novice and pair up. If no novice also, stop.

    If pro, go down the row and find a novice. Copy the name of the novice and paste to the 2nd name column (at C) and then delete the entire row of the novice. If no novice can be found, seach for a pro and pair up. If no pro also, stop.

    In pseudo-code, here is my idea:

    ActiveSheet.Filter(Column C Blank Cells)

    ActiveSheet.Sort (1st level: Ascending D, 2nd level: Ascending E)

    Row.Select(First Visible Row)

    ForEachRow that is Visible
    {
    if (ColumnE.Value =/= SelectedRowColumnE.Value && NotBlank)
    {
    Copy ColumnB.Value
    Paste at SelectedRowColumnC
    Delete Row
    Row.Select (SelectedRow + 1)
    }
    }


    ActiveSheet.Filter(Column C Blank Cells)

    Row.Select(First Visible Row)

    ForEachRow that is Visible (Starting at 2nd Row)
    {
    if (ColumnE.Value is NotBlank)
    {
    Copy ColumnB.Value
    Paste at SelectedRowColumnC
    Delete Row
    Row.Select (SelectedRow + 1)
    }
    }

    1. I'm not sure if my pseudo-code even logically works
    2. I'm not sure how to translate this to VBA code because I have to handle visible cell types, create foreach loops that only has visible types etc. I don't have any experience in this!

    Any help is very much appreciated, thank you very much! :D
    Attached Files Attached Files
    Last edited by xcen; 09-07-2013 at 04:59 PM.

+ 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. click to run, print current page then copy and past cells in to next avalable space.
    By ryannoble in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2013, 05:27 PM
  2. Delete rows with cell values equal to or greater than current week number
    By Pradeep M B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2013, 09:39 AM
  3. Cell color changes regarding current and past due dates
    By tuckerbunch in forum Excel General
    Replies: 2
    Last Post: 01-19-2013, 03:28 AM
  4. Macro to copy 6 tabs to new sheet and past as values.
    By MelPilgrim in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2012, 05:55 PM
  5. [SOLVED] Can I lock cell contents after current date is past?
    By Excel User Greg in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-16-2006, 02:50 PM

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