+ Reply to Thread
Results 1 to 10 of 10

Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    Hello,

    I am currently trying to build a macro that looks within a specific cell for wording. If the wording matches one of the numerous sheet names I have, then it will copy the entire row into that specific sheet. I would need the macro to continue that for the remaining data. Hopefully this following examples helps to make things more clear

    Column A Column B Column C
    Jane Doe Study A $1000.00
    John Doe Study B $1500.00
    Jim Doe Study C $2000.00

    The macro should read column B and determine what study it says. If it sees Study A, then copy the entire row and paste it into the Study A sheet. If it sees study B, then copy it into the Study B sheet, etc. Obviously, if it saw multiple Study A's, then I would need it to copy the row and paste below the initial pasting, so that I can get a total summary of Study A. Does this make sense? Thank you in advance for any help that can be given!

  2. #2
    Forum Contributor
    Join Date
    06-07-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    Try this - run the sub test

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-13-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    Thalassa,

    Thank you for your quick response. I apologize for not mentioning that I am new to the world of Macros in excel. I've primarily taken advantage of the macro recorder and edited the coding slightly if there was an issue. I am attaching a copy of the document that I am looking to work with. This should give you a better idea on how to help me. Thanks again.

    I need the macro to look into column G (worked project) and if the project matches one of the project sheets, copy the entire row and throw it into that tab. ALPPrE0105 would go into the ALPPrE0105 tab, ALPPrE0502 would go into the ALPPrE0502 tab, etc.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    06-07-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    For column G

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-13-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    Thalassa,

    This works great. The only issue I am running into is that when it copies the data over the new spreadsheets, it throws them onto row 2. How can I make it so it throws them starting on row 3? The reason I ask is because row two has specific rates that need to be calculated. I am trying to understand your code so I know where to make the edits.

  6. #6
    Forum Contributor
    Join Date
    06-07-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    Strange. Maybe

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-13-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    I see that you changed the offset to 2. That makes each paste be separated by a blank row. I will look more into your code and see if there is something I am missing. I appreciate your help! Thanks again!

  8. #8
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    csch123, When you ran Thalassa's code with offset(1) did you have any rates in cell A2 or was it blank at the time? if no then that is what is causing your problem. If you are not going to have A2 populated before running the code you can always run with offset(2) and delete the blank rows afterwards i.e. something like
    Please Login or Register  to view this content.
    Last edited by WasWodge; 06-13-2012 at 02:47 PM. Reason: B to A
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  9. #9
    Registered User
    Join Date
    06-13-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    WasWodge,

    Row 2 only has data in certain columns. I went forward with your coding and it looks to solve the issue of the extra rows. Thanks for your help!

  10. #10
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Macro Help: IF specific wording is found in a cell, THEN copy entire row to new sheet

    Glad it helped (hopefully someone will come in with a way to select a specific cell and then offset each row afterwards to save doing the deletes. There must be a way, Just haven't got my head clear enough to work it out at the moment)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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