+ Reply to Thread
Results 1 to 16 of 16

Move Entire Row To Different Worksheet Based On Exact Cell Value

  1. #1
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Move Entire Row To Different Worksheet Based On Exact Cell Value

    Hi there

    I apologise if this has been solved but I have searched and can't find the answer. I have 'stitched' bits of code together and feel so close to solving this. I have this working but it won't 'loop' and therefore only completes the task for individual rows.

    In a nutshell I search Sheet 1, Column Q, Row 3 onwards for a set value and then move the entire row to Sheet 3, Row 3 onwards. My code works but I have to run it 10 times if there are 10 rows that contain the value of 1 in them.

    As you can probably tell, I'm useless at VBA!

    Here is my code....

    Please Login or Register  to view this content.

    If I want to search for a value of 2 and move to sheet 5 then I have to change theses value and keep running again.

    I would like to add this to my code but don't know how to?

    Please Login or Register  to view this content.
    I can add a sample sheet if required but basically I'm just trying to look at everything in column Q from row 3 onwards so wasn't sure if it was needed as the rest of the row data is irrelevant.

    Thanks for reading this.
    Steve
    Last edited by st3v3y; 06-03-2014 at 06:07 AM.

  2. #2
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Thanks for heads up Fotis!

    I wondered how everyone did that. Looks better than Bold too!

    Steve

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Hi John and thanks for the quick reply.

    That did manage to copy the desired rows from Sheet 1 but did not delete them.

    I'll try and manipulate it. My initial attempt failed though.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    This should do the deleting. You have to delete from the bottom up.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Hi John

    Sorry but replacing the previous end to your code with the latest one did not make any difference. Nothing gets deleted.

    Thanks
    Steve

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Can you attach a sample where it doesn't work? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  8. #8
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Yeah of course. I just need to get rid of some sensitive information first.

  9. #9
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    I've deleted everything I've had to.

    st3v3y.xlsx

  10. #10
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Hi John

    I just tried the code on the Workbook I posted above and it worked!?

    I will now try to implement this into my original workbook and figure out why it didn't work the first time around.

    I will update this thread once I've done that but for now, thank you.

    Steve

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    I just tested it on the example you provided and it worked for me? Here is the code I used?

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Hi John

    It still won't delete on the original sheet but that is ok because I can just create new sheets and it works fine. I have also managed to add other Cell Values and moved them to different sheets so this is great for me!

    However if I have a cell value that is UK1 instead of 1 then the above code ignores this. Can this be added to your code?

    Thanks
    Steve

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    You can add another case statement:

    Please Login or Register  to view this content.
    Place before your End Select line.

  14. #14
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    Also note: Text values need to be enclosed with quotations as above.

  15. #15
    Registered User
    Join Date
    06-03-2014
    Posts
    9

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    I was setting the value as UK1 and not "UK1". All works perfectly.

    Thanks a lot John

  16. #16
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Move Entire Row To Different Worksheet Based On Exact Cell Value

    You're welcome. Glad to help out and thanks for the feedback.

+ 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] Move entire row to new worksheet based on specific value
    By D0lph1n in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-16-2014, 11:29 PM
  2. Move entire row to another worksheet based on cell value
    By bdf0827 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 04-09-2014, 07:01 AM
  3. [SOLVED] Move entire row to another worksheet based on cell value
    By jesseg005 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-03-2013, 12:52 PM
  4. [SOLVED] move entire row to another worksheet based on cell value
    By Berndene in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-14-2012, 10:13 AM
  5. [SOLVED] Move entire row to another worksheet based on cell value
    By mmctague in forum Excel General
    Replies: 11
    Last Post: 06-26-2012, 12:43 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