+ Reply to Thread
Results 1 to 25 of 25

Move Row based on a cell value then merge and unmerge cells - attached sample workbook

  1. #1
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Thumbs up Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Hi all,
    I am very new to VBA and this is a bit over my head. I am creating a training plan and need to make it as easy as it can be for other users. I have attached a sample workbook.
    • If someone inserts a row at the bottom of the table and in the trainer cell they type a name, the macro would automatically move the row to where the rest of the same name under trainer is. IE if they enter "Beta", then the whole row would be moved up to where the rest of the trainer BETA are
    • then column B would unmerge and then merge again included the new "beta" trainer.

    I hope someone can help, I found codes merging horizontal and difficulty understanding how to change to vertical.

    Thank you so much in advance!
    Attached Files Attached Files
    Last edited by SereneSea; 02-10-2022 at 11:39 AM. Reason: solved

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Hi, welcome to the forum.
    One thing you should seriously try to avoid is MERGED cells, they llok nice on the sheet but are a P in the A when it comes to processing.
    I will download your file and see if what you're explainign is clear to me, but honestly, avoid MERGED cells, I'm not the only one that's going to tell you this
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Thank you so much, the only reason I am using the merged is that it looks nice on the Gantt chart and this is used only for visualization on the chart.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Here goes nothing:
    The file points to 'PTL Training Plan 2021 - Copy.xlsm' which is unreachable for us.
    There are NO macro's in the file so I don't knwo what you're using.
    Avoig external links in attached samples and include the macro syou use.
    Try again

  5. #5
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    I am so sorry! I am new at posting! I have attached again. I hope it works.
    Attached Files Attached Files

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Well you can merge it when you create the Gantt Chart, but Okay, it can be Unmerged and Meged Again but I don't see the macro anywhere

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,458

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. As you are new here, I will do it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  8. #8
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    I do not have a macro yet for it, I do not know where to start.

  9. #9
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    I apologize. It wont happen again. Also, I just tried adding a link and I got an error that I need to post a few times before I can paste Links.

    error link.JPG

  10. #10
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Quote Originally Posted by Keebellah View Post
    Well you can merge it when you create the Gantt Chart, but Okay, it can be Unmerged and Meged Again but I don't see the macro anywhere
    Except that when the other users add data I wont be managing it and anything that will reduce the amount of work they would need to do is helpful.

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Try this one, if you change the table lay-out like you did with this version (it's different than the table in Example 2 ) the you will have to change the macro code too if it affects the Trainer column
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Quote Originally Posted by Keebellah View Post
    Try this one, if you change the table lay-out like you did with this version (it's different than the table in Example 2 ) the you will have to change the macro code too if it affects the Trainer column
    Thank you so much its absolutely perfect!!! Thank you for all your help and I apologize for the errors.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    You're welcome
    We all learn from errors, no problem

  14. #14
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Quote Originally Posted by Keebellah View Post
    You're welcome
    We all learn from errors, no problem
    Sorry to bother you again, but I have encountered an error. If there is only one instance of a trainer, clicking on the botton does not add the name and it leaves a blank cell in B. I have attached the sheet and highlighted the row for what I mean.
    Attached Files Attached Files

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    My msitake, I had that one in mind but when the other worked forgot to test it.
    Works now
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Quote Originally Posted by keebellah View Post
    my msitake, i had that one in mind but when the other worked forgot to test it.
    Works now
    thank you so much!!!!

  17. #17
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Sorry to bother you again, I received some feedback and the users would prefer to have the "test" be the one that's the merged and grouped instead. When I changed the code for the tblRow to 2, it does merge it but not move it up and group it with the others. What else do I have to change this in the code to make it possible? Is it also possible to also change the trainer in alphabetical so its still in a way groups it too (unless it already does that)? I also attached example.
    Attached Files Attached Files
    Last edited by SereneSea; 02-10-2022 at 07:30 PM.

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    You forgot to change the column that is sortet, now is Trainer change it to Test but the sorting will not be nice because after Test 1 it will Test 10 and Test 2 will be somewehre below.
    If you want it sorted nicely chnage Test 1 to Test 01 and Test2 to Test 02 etc up to Test 9

  19. #19
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Thanks! It worked!!

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    You’re welcome
    Happy coding

  21. #21
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    I have another question, and sorry to bother you again, I totally understand if your annoyed!! I am also learning so much.

    What lines in the code do I have to change to have instead of active sheet to the actual sheet title. I have the graph on a second sheet for larger viewing and I would like to use the same buttons on the second sheet (as sort of viewing filter), but control the sheet with the table. When I copy the buttons on the second sheet it works only on active sheet which the table is not on that sheet.
    Thanks in advance.

  22. #22
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Don’t worry, there’s nothing wrong with asking questions, and no, I’m not annoyed, if you don’t ask you’ll never get an answer and yes the macro is written for the worksheet with the table
    I do not understand why the button needs to be copied to the sheet with the Gantt chart

  23. #23
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    only for viewing purposes. The gantt chart is fairly large and would be nice to view it on its own without the table but still be able "to group and filter" as the users are viewing it. - Almost like a dashboard page. I have added 2 other buttons for the different categories so to be able to switch between them.

  24. #24
    Registered User
    Join Date
    02-09-2022
    Location
    EU
    MS-Off Ver
    2016
    Posts
    14

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    I added example.
    Attached Files Attached Files

  25. #25
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move Row based on a cell value then merge and unmerge cells - attached sample workbook

    Here's my approach and simplified the macros
    Attached Files Attached Files

+ 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] To get Test Result based on entries in column cells. Sample excel attached.
    By pavanbhoyar in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-23-2021, 01:39 PM
  2. Copying specific range (sample workbook attached as not easy to explain in title!)
    By stevoDE in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-03-2017, 05:01 PM
  3. Vlookup with multiple criteria (Sample workbook attached)
    By swade730 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-26-2015, 01:20 PM
  4. [SOLVED] Needed: VBA code to edit/update data (sample workbook attached)
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-23-2015, 01:30 PM
  5. Merge and unmerge cells based on cell value.
    By Jamison in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2012, 01:08 AM
  6. is it possible to merge consistent date ranges? sample attached
    By justinhampton81 in forum Excel General
    Replies: 2
    Last Post: 03-08-2012, 07:24 PM
  7. Conditional Format Cell Based on Another Cell (sample attached)
    By justinhampton81 in forum Excel General
    Replies: 1
    Last Post: 08-24-2010, 05:54 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