+ Reply to Thread
Results 1 to 10 of 10

Cut, Paste Row based on cell value

  1. #1
    Registered User
    Join Date
    08-18-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    20

    Cut, Paste Row based on cell value

    Hi,

    I am struggling to do a simple thing.

    I have a sheet with a list of project called Portfolio and another with the same structure called Prospect & Closed.

    I would like to cut and paste the rows from the Portfolio sheet at the end of the Prospect & Closed one if the rows have either the value "Closed" or "Removed" in column B of the Portfolio Sheet.

    My data starts at row 7 in both sheets and the number of row is dynamic.

    I have searched for solution but none seem to work. The closest I got was with:
    Please Login or Register  to view this content.
    This code currently gives me a Run-time error 1004.

    Any would be greatly appreciated as I am a bit of a VBA beginner.

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,111

    Re: Cut, Paste Row based on cell value

    Hello GV,

    Try the following simple Auto Filter code (activate it from your active sheet "Portfolio"):-


    Please Login or Register  to view this content.
    As you can see, I've used the actual sheet code to reference the sheets but you can change these to your sheet tab names if you like.

    I've attached a mock-up work book for you to peruse based on what I believe your work book to look like. Click on the Copy/Paste button to see it work.

    Do you need the "used" data cleared from the Portfolio sheet? If so, add the following line of code:-

    Please Login or Register  to view this content.
    just above this line of code:-

    Please Login or Register  to view this content.
    I hope that this helps.

    Cheerio,
    vcoolio.
    Attached Files Attached Files
    Last edited by vcoolio; 12-15-2015 at 06:43 AM. Reason: Add delete line of code.

  3. #3
    Registered User
    Join Date
    08-18-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    20

    Re: Cut, Paste Row based on cell value

    Hi Vcoolio,

    Thanks heaps for your answer. it works like a charm.

    I did add the line to remove "Used Data".

    One last thing is there a way to paste only the values with the format?

    Thanks,

    Gv

  4. #4
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,111

    Re: Cut, Paste Row based on cell value

    Hello GV,

    This slight modification to the code should do that for you:_


    Please Login or Register  to view this content.
    Cheerio,
    vcoolio.

  5. #5
    Registered User
    Join Date
    08-18-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    20

    Re: Cut, Paste Row based on cell value

    Thanks a lot for that slight modification.

    Cheers,

    GV

  6. #6
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,111

    Re: Cut, Paste Row based on cell value

    Hello GV,

    No worries. Glad that I could help.

    Cheerio,
    vcoolio.

  7. #7
    Registered User
    Join Date
    08-18-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    20

    Re: Cut, Paste Row based on cell value

    Hi,

    I have an additional question.

    Before copying and pasting, I would like to check wether there are any project to close or remove and display a warning message and exit the macro if there is nothing to transfer.

    I have the following code but it doesn't seem to work and I can't figure why

    Please Login or Register  to view this content.
    Thanks again for your help,

  8. #8
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,111

    Re: Cut, Paste Row based on cell value

    Hello GV29,

    Try changing this :-

    Please Login or Register  to view this content.

    to this

    Please Login or Register  to view this content.
    That should get the message box to show up.

    Cheerio,
    vcoolio.

  9. #9
    Registered User
    Join Date
    08-18-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    20

    Re: Cut, Paste Row based on cell value

    Thanks for your prompt answer.

    Just tried to change it to
    Please Login or Register  to view this content.
    but it is still not working properly.
    It displays the warning message regardless of wether their are project with closed, removed or prospects or not.

  10. #10
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,111

    Re: Cut, Paste Row based on cell value

    Hello GV,

    I was wondering if that would be the case. Anyway, I've knocked up the following incorporating warnings with the code I supplied earlier:-

    Please Login or Register  to view this content.
    You'll get two message boxes. One warning you that not all cells are marked for transfer and when you click OK, a second message box will appear asking if you wish to continue anyway (you may have a couple of rows that you may want to transfer anyway). If you click on NO, the sub will be exited.

    If the whole data set (as per my test work book at least!) is marked for transfer, you'll get the second message box only.

    For whatever reason, the site's file uploader does not work, so following is a link to my updated test work book for you to peruse:-

    https://www.dropbox.com/s/ravrva671v...r%29.xlsm?dl=0

    Cheerio,
    vcoolio.

+ 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. Replies: 0
    Last Post: 09-28-2015, 12:34 PM
  2. [SOLVED] Find a row based on cell value, copy cell in different column, paste below
    By gaker10 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-02-2014, 07:12 AM
  3. [SOLVED] cut/paste row based on cell value
    By sinistr0311 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-20-2013, 02:52 AM
  4. Replies: 3
    Last Post: 07-25-2012, 07:54 AM
  5. Replies: 2
    Last Post: 11-08-2011, 11:10 AM
  6. Replies: 3
    Last Post: 07-15-2010, 08:49 AM
  7. Paste Into Row Based on Another Cell's Value
    By atkikj2 in forum Excel General
    Replies: 2
    Last Post: 03-01-2008, 12:07 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