+ Reply to Thread
Results 1 to 16 of 16

VBA code to move row if P6:P29 equal text "Complete"

  1. #1
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    VBA code to move row if P6:P29 equal text "Complete"

    From B6:P29 i have a range of cells with text and numbers. I need a vba code to if any cell P6:P29 equal text "Complete" then its related row B:P will automatically go to B58:P58.

    Example

    B4: price C4: date D4: 0 E4: 0 F4: 0 G4: 0 H4: boat I4: 0 J4: car K4: 0 L4: 0 M4: 0 N4: 0 O4: 0 P4: Complete
    B5:
    B6:

    P4 was "Complete" then row B4:P4 will be moved to B58:P58.
    Before:
    B58: C58: D58: E58: F58: G58: H58: I58: J58: K58: L58: M58: N58: O58: P58:

    After:
    B58: price C58: date D58: 0 E58: 0 F58: 0 G58: 0 H58: boat I58: 0 J58: car K58: 0 L58: 0 M58: 0 N58: 0 O58: 0 P58: Complete

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: VBA code to move row if P6:P29 equal text "Complete"

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: VBA code to move row if P6:P29 equal text "Complete"

    I attached a sample worbook.
    Attached Files Attached Files
    Last edited by Mr.Castle; 01-01-2020 at 04:42 PM.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: VBA code to move row if P6:P29 equal text "Complete"

    Please Login or Register  to view this content.
    Assumes that Row 58 is the last row. You may need to clean up your workbook as when I initially ran this it came us with row 78 as your last. I deleted 59 - 78 and then ran it and it was all ok.

  5. #5
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: VBA code to move row if P6:P29 equal text "Complete"

    I deleted 59 - 78 also , but for some reason its moving below 58.

  6. #6
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: VBA code to move row if P6:P29 equal text "Complete"

    Thank you alansidman the code is working well.

  7. #7
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: VBA code to move row if P6:P29 equal text "Complete"

    alansidman Is it possible instead of moving only to row 58 to move to the last empty rows from B52:P58 , so it would be possible to move multiple rows "complete" at the same time?

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: VBA code to move row if P6:P29 equal text "Complete"

    the line
    Please Login or Register  to view this content.
    determines the last row. Set data in A51 and nothing after that will do what you want.

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA code to move row if P6:P29 equal text "Complete"

    to move to the last empty rows from B52:P58 , so it would be possible to move multiple rows "complete" at the same time?
    Perhaps...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  10. #10
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: VBA code to move row if P6:P29 equal text "Complete"

    Hi Sintek ,
    I Tried your code.
    Date to complete moved to E instead of J and Status moved to G instead of P.

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA code to move row if P6:P29 equal text "Complete"

    Works for your uploaded sample...Anything change?
    EDIT...

    My bad... Had to unhide all your columns then run code
    Attached Files Attached Files
    Last edited by sintek; 01-03-2020 at 12:50 PM.

  12. #12
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: VBA code to move row if P6:P29 equal text "Complete"

    Hi sintek after unhiden all the cells the code worked , but if there no "Complete" in J6:J29 it shows no cells available, and erases part of the page. Its possible to ignore "Complete" from J6:J29 if there isnīt any?
    Last edited by Mr.Castle; 01-03-2020 at 04:54 PM.

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA code to move row if P6:P29 equal text "Complete"

    but if there no "Complete" in J6:J29
    Do you mean in P6:P29
    and erases part of the page
    Please clarify
    Please Login or Register  to view this content.

  14. #14
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VBA code to move row if P6:P29 equal text "Complete"

    .......................deleted......................
    Last edited by sintek; 01-04-2020 at 06:02 AM.

  15. #15
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA code to move row if P6:P29 equal text "Complete"

    What about empty rows : e.g. row 6
    formulas in column A needs to be updated for pasted rows ?
    Last edited by PCI; 01-04-2020 at 12:44 PM.
    - Battle without fear gives no glory - Just try

  16. #16
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: VBA code to move row if P6:P29 equal text "Complete"

    Sintek the code is working perfectly.

    Thank you

+ 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] SUM of positive values if text is equal to "textA" and "textB" - too few arguments
    By meatychi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-08-2018, 10:45 AM
  2. Google Sheets - Move Row with "Complete" to a new sheet within the same workbook
    By msquared2 in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 08-24-2018, 02:02 PM
  3. Formula to move row to new tab if Column D contains text "complete"
    By IsabellaLearning in forum Excel General
    Replies: 4
    Last Post: 08-10-2014, 08:38 PM
  4. [SOLVED] Code that copies row of data to another sheet based on text "Complete"/"Delete"
    By Dremzy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-20-2014, 05:51 PM
  5. Replies: 2
    Last Post: 04-20-2014, 11:18 AM
  6. [SOLVED] Delete Rows if a cell does not equal "Finished" or "Complete"
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-27-2013, 12:40 PM
  7. [SOLVED] If there is any text in column "A$" on "sheet1" then move cell to column "A$" on "sheet2"
    By ckgeary in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2013, 08:28 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