+ Reply to Thread
Results 1 to 9 of 9

Copy Rows to sheet if column value >40, multiple sheets

  1. #1
    Registered User
    Join Date
    12-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    27

    Question Copy Rows to sheet if column value >40, multiple sheets

    Hi. I am very new to this and I assume I am needing macros rather than formula to complete this task.
    basically I have 12 sheets of data, if column H (in any of these sheets & rows) has a currency value greater than 40;
    I want to copy the entire row/s to Sheet16 named "Major" - which has the exact same columns and formatting.
    I need this to be automatic.
    What code do I need, where do I put the code? Thank you

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Copy Rows to sheet if column value >40, multiple sheets

    Hello,

    Try and see if this code helps. Add it to a regular module and run it.

    Please Login or Register  to view this content.
    thanks

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Copy Rows to sheet if column value >40, multiple sheets

    Try this......
    Please Login or Register  to view this content.
    Last edited by sktneer; 12-04-2013 at 12:30 AM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Registered User
    Join Date
    12-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Copy Rows to sheet if column value >40, multiple sheets

    Awesome, so do I add this to the Major sheet, or to each of sheets with data? right click on sheet, view code, paste? sorry i am still learning

  5. #5
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Copy Rows to sheet if column value >40, multiple sheets

    You will have to add a module. Read this for more information. http://www.jlathamsite.com/Teach/Excel_GP_Code.htm

  6. #6
    Registered User
    Join Date
    12-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Copy Rows to sheet if column value >40, multiple sheets

    Theres an error msg appearing, other than that its works really well :D

    Sub SumaryData()

    Dim sh As Worksheet
    Dim lrOrigen As Long
    Dim lrTarget As Long

    Application.ScreenUpdating = False

    For Each sh In ThisWorkbook.Worksheets

    If sh.Name <> "Major Projects" Then
    lrOrigen = sh.Range("A1").CurrentRegion.Rows.Count
    lrTarget = Sheets("Major Projects").Range("A1").CurrentRegion.Rows.Count + 1
    'Filter the data
    sh.Range("A1").CurrentRegion.AutoFilter Field:=8, Criteria1:=">40000"
    sh.Range("A1").CurrentRegion.Offset(1).Resize(lrOrigen - 1).Copy _
    Destination:=Sheets("Major Projects").Range("A" & lrTarget)

    'clear the filters
    sh.Range("A1").CurrentRegion.AutoFilter
    End If
    Next
    Application.ScreenUpdating = False
    End Sub

  7. #7
    Registered User
    Join Date
    12-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Copy Rows to sheet if column value >40, multiple sheets

    Also, if the macro is run twice, then the data just keeps being generated, rather than only adding new entries, is there a way around this? thanks again

  8. #8
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Copy Rows to sheet if column value >40, multiple sheets

    Press Alt+F11 to open VBA window, then click on Insert--> Module and then paste the code given below in the opened VBA Code window. You are done.

    The code given below will run only once i.e. if you run it repeatedly without adding new rows in any of your 16 sheets with a value >40 in col. H. So if you run this code twice by mistake it will not do the same action again.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-03-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Copy Rows to sheet if column value >40, multiple sheets

    This code is great ! Thank you Sooo much!

    quick question, how do I exclude it from pulling my Row ONE on each sheet, as to not add the headers ?

+ 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 column A from multiple sheets onto summary sheet
    By fabrecass in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2012, 05:46 PM
  2. Search for Multiple String Values on Multiple Sheets and Copy Rows to New Sheet
    By rrtikker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2012, 12:21 PM
  3. Replies: 1
    Last Post: 07-29-2011, 05:03 AM
  4. Copy rows from master sheet to other sheets if certain cell in column is blank
    By nadiaraciti in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-29-2011, 02:05 AM
  5. copy rows from 1 sheet to multiple sheets
    By GatorHunter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-04-2010, 08:26 AM

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