+ Reply to Thread
Results 1 to 12 of 12

Automatically cutting and pasting a row to another sheet when 2 conditions are met.

  1. #1
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    Hello Excel Gurus!

    First off, thanks for even reading this. Your assistance is priceless. This is only the 2nd time I've consulted with the greats and I am very novice (1st time) user of Visual Basic and Macros.

    I did some research and found some examples online but I can't get them to work. I am hoping you can help.

    A little background:

    This is a 2 sheet worksheet for a maintenance company. 1st sheet is labeled "Active" and the 2nd sheet is labeled "Completed". The goal is for when employees fill in 'both' the 5th and 6th column (any text, number, date, etc) on the Active sheet, that the entire row is cut and pasted into the Completed sheet. Sounds simple enough, right!? haha, much to my surprise, not that easy. I tried the macro recorder and that was an epic fail.

    Here is what I have so far. Excel is giving back a 'Run-time error '13'' - type mismatch and it is highlighting this code as the issue: Worksheets("Completed").Cells(b + 1, 1).Select

    -----------------------------------------------------------------------------------------------------------------------------------------
    Please Login or Register  to view this content.
    --------------------------------------------------------------------------------------------------------------------------------------

    Some fantasies of mine with this project - I say fantasies because I don't know if they are possible

    1. Can this happen automatically upon saving the worksheet or even just as soon as something goes into those two fields then the macro runs automatically?

    2. Can we program Excel to delete the row it leaves behind?

    THANK YOU for any responses!
    Attached Files Attached Files
    Last edited by alansidman; 04-15-2019 at 10:43 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    .
    Forum rules require you to place your code between the hash symbols located on the menu. You can edit your original post by highlighting the code, then click on the hash symbol.

    Here is the code you were seeking :

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    Thanks for responding!

    It is changing it to this and giving an error that says "Compile error: Expected: Then or GoTo"
    Please Login or Register  to view this content.

    Any help is appreciated! Thanks!
    Last edited by alansidman; 04-15-2019 at 10:46 PM.

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

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. Because you are new to the forum, I have added them for you today. Please read our forum rules and abide by them in the future.)

    Additionally, do not ignore requests from senior members and moderators. Future action of this type may result in infractions or banishment. We take our rules seriously.
    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

  5. #5
    Forum Contributor banaanas's Avatar
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    199

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    My take on the matter, see attachment for a working example. Here is the code located in the worksheet code:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Tuomas "Banaanas" Savonius
    Trying to give back now when I actually can do some VBA

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    .
    Onefynebarraza

    What line of code is highlighted when the error shows ?

  7. #7
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    Hey Logit!

    Thanks for responding!

    The code that highlights is this one:
    Please Login or Register  to view this content.
    It looks like this once I press Ok:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    Oh wow, it looks much better this way! Thanks Alan!

  9. #9
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    BANAANAS!!!! You did it!!!

    Thanks for showing me how to add in firing when a change is made. So much easier than what I was seeing other places. You all are the best!!!

  10. #10
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    Banaanas,

    I noticed that the cell will stay blank on the other side. Is there code to delete the cell after it has been removed?

    Sometimes there will be tasks that will finish before others and it would be convenient not to have to delete the line after it moves over.

  11. #11
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    .
    VBA won't let you break lines of code like this :

    Please Login or Register  to view this content.
    You are best to keep the entire line together :

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor banaanas's Avatar
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    199

    Re: Automatically cutting and pasting a row to another sheet when 2 conditions are met.

    Quote Originally Posted by Onefynebarraza View Post
    Banaanas,

    I noticed that the cell will stay blank on the other side. Is there code to delete the cell after it has been removed?

    Sometimes there will be tasks that will finish before others and it would be convenient not to have to delete the line after it moves over.
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

+ 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. Macro for searching and cutting and pasting to another sheet
    By Danielle22 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2018, 03:52 PM
  2. Excel 2013 - Appending one sheet to another without cutting and pasting
    By TomCruise in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-26-2014, 09:36 AM
  3. Replies: 2
    Last Post: 07-28-2014, 12:15 PM
  4. cutting and pasting row in other sheet if cell is empty
    By flunzy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-02-2014, 09:42 AM
  5. Cutting row and pasting into new sheet based on criteria
    By goose1000 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-18-2011, 11:54 PM
  6. Cutting/Pasting Data From One Sheet To Another
    By MCatz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2010, 12:23 PM
  7. [SOLVED] cutting and pasting rows from one sheet to another generates error
    By JT Spitz in forum Excel General
    Replies: 7
    Last Post: 02-14-2006, 03:10 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