+ Reply to Thread
Results 1 to 12 of 12

Moving Rows based on cell content

  1. #1
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Moving Rows based on cell content

    The code below will move rows where column E contains "43A" to sheet EE. I have a couple of questions.

    1. How can I concatenate E and G to make their criteria together to move to EE?
    2. If I have other combos to move to other sheets beside EE can I recopy the code below the loop line and modify criteria?


    Please Login or Register  to view this content.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Moving Rows based on cell content

    I'm not exactly sure what you are asking so I took a stab at it.
    I also cleaned up your variables a little bit. When you know what something is going to be you should declare it as such, other wise everything is variants and that's not good coding.

    Please Login or Register  to view this content.
    Last edited by skywriter; 12-28-2015 at 10:23 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: Moving Rows based on cell content

    If I delete this part

    Please Login or Register  to view this content.
    It finds and moves the 43A rows. With the above code inserted no rows are moves.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Moving Rows based on cell content

    Here's a sample workbook I created. Look at it and see what it does and maybe you'll figure out what is different with yours and be able to fix it.
    You can post your workbook also and tell me what you want to do and I'll help you.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: Moving Rows based on cell content

    I attached a file. Not sure why it does not work...thanks
    Attached Files Attached Files

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

    Re: Moving Rows based on cell content

    Another option:

    Please Login or Register  to view this content.
    Red indicates criteria's 1 and 2

    BTW - Code in Post#2 works for me.
    Last edited by JOHN H. DAVIS; 12-29-2015 at 02:52 PM.

  7. #7
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Moving Rows based on cell content

    Hi Bill,
    The issue is that the term you are searching for is "hire" and your sheet has "HIRE". It's case sensitive, Excel doesn't see those two as the same word.

    There's a few things we can do. If you want it to match the word HIRE and not the lower case hire, you can change the word in the code to all upper case, so just change the word in your code to "HIRE".

    Another way is to use LCASE or UCASE. Excel uses LCASE to convert whatever string you feed it to all lower case letters. The way I'm using it the change is only made in memory, the results on your sheet will stay they way they are, upper case on sheet "EE". UCASE converts whatever string you feed it to all upper case letters.

    So if I simply want to match the word "hire" and I want the match to happen without regard to case I can use either LCASE to convert whatever is in your sheet to all lower case and search for the word "hire" or I can use UCASE to convert to all upper case and search for the word "HIRE".

    I chose the LCASE version for demonstration purposes.

    Please Login or Register  to view this content.
    Last edited by skywriter; 12-29-2015 at 03:02 PM.

  8. #8
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: Moving Rows based on cell content

    That work....Thank you so much.

    One more question...I want to add 43C - hire rows to move to Sheet EF

    Is there an easy way to add to my above code to move both at the same time?

  9. #9
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Moving Rows based on cell content

    What is it you want to do?
    Change the criteria to 43A or 43C and hire?

  10. #10
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: Moving Rows based on cell content

    It already moves 43A and hire to sheet EE

    and

    Move 43C and hire to sheet FE Set f = Sheets("FE")

    Two separate sheets and move depending on E and G contents

    Thanks
    Last edited by billisnice; 12-29-2015 at 09:11 PM.

  11. #11
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: Moving Rows based on cell content

    This is what i am trying to accomplish...

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: Moving Rows based on cell content

    I got it to work. I could not have done it without skywriter help. Thank skywriter! It may not be pretty...

    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. [SOLVED] Moving entire row from one spreadsheet to another based on content in a particular cell
    By appchick21 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-11-2013, 02:30 AM
  2. Insert rows with content based on a cell's value.
    By diegochavezl in forum Excel General
    Replies: 0
    Last Post: 08-23-2012, 02:06 PM
  3. Replies: 0
    Last Post: 05-21-2012, 06:59 AM
  4. Replies: 3
    Last Post: 06-24-2011, 03:00 AM
  5. Copy rows based on cell content
    By ashncg in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-14-2011, 11:19 AM
  6. Hide rows based on cell content
    By garyi in forum Excel General
    Replies: 9
    Last Post: 11-14-2010, 09:10 AM
  7. Hiding Rows Based on Cell Content
    By ChristineJ in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2009, 03:55 AM
  8. Moving rows to another worksheet based on content of cell
    By 5tin@ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2005, 10:25 AM

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