+ Reply to Thread
Results 1 to 11 of 11

Macro to copy rows based on a critera and copy the name of the column

  1. #1
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Macro to copy rows based on a critera and copy the name of the column

    Hey Guys,

    I need help with a macro to copy part of a certain rows based on criteria, then add the name of the column and the value.
    The macro compares any of the values in Range E3:M1300 whether they are bigger than the value in O1.
    If a match is found (for example cell F3 is bigger than O1), to copy A3:C3 on a new row in Sheet Results , on column D to copy the name of the section, and on column E to copy the actual Value.

    I have included a test file with data.testexamplev2.xlsx

    Thank you very much in advance!

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

    Re: Macro to copy rows based on a critera and copy the name of the column

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Macro to copy rows based on a critera and copy the name of the column

    Well, John...it took me more time to write my post, than you to solve it!

    Works great! Thank you so much!

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

    Re: Macro to copy rows based on a critera and copy the name of the column

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

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to copy rows based on a critera and copy the name of the column

    I just thought that I would throw this in. The only difference is that if any changes are made to the data and you want to refresh the "Results" sheet, I think that John's macro would simply add the changes to the existing data. The following macro would avoid that issue. I'm not sure if this helps.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Macro to copy rows based on a critera and copy the name of the column

    Mumps, that's actually an awesome suggestion! This way if they press the macro button twice, it won't double the data.

    Thank you very much for your addition! Now the macro is perfect!

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to copy rows based on a critera and copy the name of the column

    My pleasure.

  8. #8
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Macro to copy rows based on a critera and copy the name of the column

    Guys, one thing that came up. Where do I put .PasteSpecial xlPasteValues? Some of the cells the macro copies are formulas and I want only the result of the formulas.
    Last edited by dreddster; 10-10-2013 at 09:11 AM.

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to copy rows based on a critera and copy the name of the column

    Try:
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Macro to copy rows based on a critera and copy the name of the column

    Works great, thank you again Mumps!

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to copy rows based on a critera and copy the name of the column

    Glad it worked out.

+ 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 to copy rows based on column criteria to a new sheets
    By Scott821 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2012, 01:55 AM
  2. [SOLVED] macro to copy rows based on number in column
    By amenu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-03-2012, 06:02 AM
  3. Copy data from one column to another based off certin critera
    By rudolphe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2009, 05:18 PM
  4. [SOLVED] MACRO - copy rows based on value in column to another sheet
    By Michael A in forum Excel General
    Replies: 1
    Last Post: 03-04-2005, 11:06 PM
  5. [SOLVED] MACRO - copy rows based on value in column to another sheet
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-04-2005, 09:06 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