+ Reply to Thread
Results 1 to 21 of 21

Move data to a different row, contingent upon data in another column

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    10

    Move data to a different row, contingent upon data in another column

    I'm a real estate investment analyst and I come across this situation quite frequently. If I'm able to find a solution to this it will save me hours of work, weekly!

    Example situation:

    In column C there is only data in every 2-6 cells. In column G there are certain cells with a specific value, which should be on the same row as the cell in column C, when there is data in the cell in column C.

    1 C G H
    2 813.00 pestfee 5.00
    3 petrent 20.00
    4 rent 1,010.00
    5 ugarbr 18.00
    6 park 25.00

    In the above example, what I'm trying to do is automatically move the data in cells G4 and H4 to row 2 (because there is data in cell C2). As a side note, all the other data in columns G and H (besides G4 and H4) are inconsequential.

    Thanks!

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Move data to a different row, contingent upon data in another column

    JonnyOctagon it might be helpful if you would upload an example in an Excel workbook to the forum. (no pics or screenshots ... saves retyping data). Be sure to desensitize the data.

    Include a small section of BEFORE and another AFTER showing what you want.

    If you are not familiar with how to do this:
    To attach a file to your post,
    • be sure to desensitize the data
    • click “Go Advanced” (next to Post Quick Reply – bottom right),
    • scroll down until you see “Manage Attachments”, click that,
    • click “Browse”.
    • select your file(s)
    • click “Upload”
    • click “Close window”
    • click “Submit Reply”

    The file name will appear at the bottom of your reply.
    Dave

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    10

    Re: Move data to a different row, contingent upon data in another column

    I have attached a BEFORE file of how it is now as well as an AFTER as how I would like it to be re-arranged. This, of course, is just a small sample of the entire sheet.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Move data to a different row, contingent upon data in another column

    Failing to see the logic behind the AFTER workbook is it possible BEFORE/AFTER are the other way around?

  5. #5
    Registered User
    Join Date
    06-23-2014
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    10
    Quote Originally Posted by FlameRetired View Post
    Failing to see the logic behind the AFTER workbook is it possible BEFORE/AFTER are the other way around?
    No, it's correct.

    The aim is to have the yellow cells in column E (as well as the adjacent cells in column F) line up in the same row with the yellow cells in column C so I can then sort the table with ascending column C values and have the corresponding rent amounts (column F) in the same rows as the square footages in column C. The rest of the data is irrelevant.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Move data to a different row, contingent upon data in another column

    If this is doable by formula I am not finding a workable approach.

    It may be doable with VBA. Unfortunately I am VBA 'lite'.

    We'll see if anyone comes up with a solution.

    In the meantime I'm sending up a "flare" to the rest of the community.

  7. #7
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Move data to a different row, contingent upon data in another column

    As FlameRetired noted, this is doable with VBA, but if you'd prefer formulas and some minor legwork, I think you can also get your results with a helper column. Namely, in N3 of my attachment, I use:

    =IF($C3<>"",INDEX($F3:$F50,MATCH("rent",$E3:$E50,0)),"")

    ...and fill down to return the next "rent" entry each time there's data in column C. You can then copy the results and paste the values in column N or F and the rent should sort alongside a sorting of column C. In the attached, I've done the formula bit but not the paste values; see if it'll work for you or if you'd rather use a VBA solution:
    Attached Files Attached Files
    Last edited by CAntosh; 08-10-2017 at 11:23 AM. Reason: typo
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,535

    Re: Move data to a different row, contingent upon data in another column

    Here's a Pivot Table/hybrid option, which will also require a little leg work.
    To make proper records out of the table on the before sheet, you will need to fill in the missing unit numbers in column A. This can be done using the method shown in the video in the second second section of this article.
    A column header, Fee, is also needed for column E. The report filter for the PT is based on this column.
    The rent amount will need to be the first column of the PT, so that it will be the primary key for sorting. The second column of the PT is the Unit number. The rest of the information is then displayed using the formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Move data to a different row, contingent upon data in another column

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 08-10-2017 at 12:10 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  10. #10
    Registered User
    Join Date
    06-23-2014
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    10

    Re: Move data to a different row, contingent upon data in another column

    Quote Originally Posted by CAntosh View Post
    As FlameRetired noted, this is doable with VBA, but if you'd prefer formulas and some minor legwork, I think you can also get your results with a helper column. Namely, in N3 of my attachment, I use:

    =IF($C3<>"",INDEX($F3:$F50,MATCH("rent",$E3:$E50,0)),"")

    ...and fill down to return the next "rent" entry each time there's data in column C. You can then copy the results and paste the values in column N or F and the rent should sort alongside a sorting of column C. In the attached, I've done the formula bit but not the paste values; see if it'll work for you or if you'd rather use a VBA solution:
    This seems to be the simplest solution and does exactly what I need. Thank you!!!

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Move data to a different row, contingent upon data in another column

    Hi Johnny,

    Thanks for the rep!

    Did you try my program?

    I think it's the simplest solution

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  12. #12
    Registered User
    Join Date
    06-23-2014
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    10

    Re: Move data to a different row, contingent upon data in another column

    Quote Originally Posted by xladept View Post
    Hi Johnny,

    Thanks for the rep!

    Did you try my program?

    I think it's the simplest solution

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    It may very well be! I just have 0 knowledge of/experience with macros (is it even a macro?? I don't even know!!) and I fear what I do not know...
    Last edited by JonnyOctagon; 08-10-2017 at 03:18 PM.

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Move data to a different row, contingent upon data in another column

    I should have realized that since I picked it up from the "flare" by FlameRetired - sorry!

    If you haven't used macros before you'll need to go to:
    File- options - trust center -trust center settings - macro settings ,
    the second option down (disable all macros with notification)

    Then - Copy the code to the clipboard

    Open your Workbook

    Press ALT + F11 to open the Visual Basic Editor.

    Select "Module" from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    *Be sure to save the book with the code as Macro-Enabled

  14. #14
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Move data to a different row, contingent upon data in another column

    I'm glad I could help, thanks for the rep!

    For what it's worth, if you're able to use macros in this document, it might be worth experimenting with xladept's solution. It definitely saves a little bit of legwork. Keep a backup save and you can always resort to either of the other two solutions if you decide you'd rather use something you have more experience implementing and adapting.
    Last edited by CAntosh; 08-10-2017 at 04:27 PM. Reason: typo

  15. #15
    Registered User
    Join Date
    06-23-2014
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    10

    Re: Move data to a different row, contingent upon data in another column

    Quote Originally Posted by xladept View Post
    I should have realized that since I picked it up from the "flare" by FlameRetired - sorry!

    If you haven't used macros before you'll need to go to:
    File- options - trust center -trust center settings - macro settings ,
    the second option down (disable all macros with notification)

    Then - Copy the code to the clipboard

    Open your Workbook

    Press ALT + F11 to open the Visual Basic Editor.

    Select "Module" from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    *Be sure to save the book with the code as Macro-Enabled
    Yep! That worked! The only question I have (since I don't have an understanding of the actual code) will this code work in any similar sheet (i.e. if the Sq Ft's and/or Rents are in different columns)? Or, what are the restrictions for it to work in it's current form?

  16. #16
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Move data to a different row, contingent upon data in another column

    xladept appears to be offline, so I hope I don't offend by jumping in - the code looks in column A for non-blank entries in order to identify the first row. It doesn't rely on the sq. ft. column at all. It then transports whatever is in columns E and F up to that row when it finds a "rent" match. If the "rent" column is going to be somewhere other than column E, then change the three instances of the number "5" in xladept's code (in the IF clause near the bottom) to the number that corresponds to the column in which the term "rent" will be found.

    Hope that helps?

  17. #17
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Move data to a different row, contingent upon data in another column

    I'll comment:

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    06-23-2014
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    10

    Re: Move data to a different row, contingent upon data in another column

    Perfect, thank you!!

  19. #19
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Move data to a different row, contingent upon data in another column

    You're welcome!

    And - Thanks for the rep!

  20. #20
    Registered User
    Join Date
    02-01-2022
    Location
    California
    MS-Off Ver
    360
    Posts
    1

    Re: Move data to a different row, contingent upon data in another column

    Looking to follow up on this 5 year old conversation.
    This only works because "Rent" Occurs in ever resident charge. Does anyone know how you can do this for the other charge codes that only occur on a select amount of residents? Without VB please.

    For example I used provided formula here for "Furniture Rent" for a different rent roll

    =IF($D8<>"",INDEX($K8:$K3904,MATCH("Furniture Rent",$I8:$I3904,0)),"")

    .. But not all residents have furniture. If this can be done, i would then be able to run a pivot table to know which unit type has furniture based on the charge code "furniture rent".

    Attachment 766129

  21. #21
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Move data to a different row, contingent upon data in another column

    Quote Originally Posted by bfret333 View Post
    Looking to follow up on this 5 year old conversation.
    This only works because "Rent" Occurs in ever resident charge. Does anyone know how you can do this for the other charge codes that only occur on a select amount of residents? Without VB please.

    For example I used provided formula here for "Furniture Rent" for a different rent roll

    =IF($D8<>"",INDEX($K8:$K3904,MATCH("Furniture Rent",$I8:$I3904,0)),"")

    .. But not all residents have furniture. If this can be done, i would then be able to run a pivot table to know which unit type has furniture based on the charge code "furniture rent".

    Attachment 766129
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. Move corresponding data of duplicate column data to one row
    By puneetjain in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-09-2016, 10:24 AM
  2. [SOLVED] move data from diff rows in 1 column into new columns based on dup data in another field
    By lxndeb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-01-2014, 11:50 PM
  3. Move Cell Data based on column data
    By bigroo1958 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2010, 11:54 PM
  4. Data Validation Contingent on another cell
    By papaexcel in forum Excel General
    Replies: 2
    Last Post: 11-24-2009, 02:02 PM
  5. Replies: 3
    Last Post: 11-27-2008, 12:02 PM
  6. [SOLVED] Macro to move data to different column based on data in another co
    By malycom in forum Excel General
    Replies: 3
    Last Post: 08-02-2005, 03:05 PM
  7. create macro to move label type data to column data
    By JonathonWood9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2005, 07:06 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