+ Reply to Thread
Results 1 to 10 of 10

Copy Rows to Existing Worksheet Based upon a Cell Value

Hybrid View

sclasen24 Copy Rows to Existing... 12-19-2013, 10:44 AM
natefarm Re: Copy Rows to Existing... 12-19-2013, 11:40 AM
sclasen24 Re: Copy Rows to Existing... 12-19-2013, 02:23 PM
natefarm Re: Copy Rows to Existing... 12-19-2013, 03:51 PM
sclasen24 Re: Copy Rows to Existing... 12-19-2013, 04:47 PM
natefarm Re: Copy Rows to Existing... 12-19-2013, 04:57 PM
sclasen24 Re: Copy Rows to Existing... 12-19-2013, 04:58 PM
natefarm Re: Copy Rows to Existing... 12-19-2013, 05:04 PM
sclasen24 Re: Copy Rows to Existing... 12-19-2013, 07:30 PM
natefarm Re: Copy Rows to Existing... 12-20-2013, 10:21 AM
  1. #1
    Registered User
    Join Date
    01-11-2013
    Location
    Wichita, KS
    MS-Off Ver
    Excel 2013
    Posts
    25

    Copy Rows to Existing Worksheet Based upon a Cell Value

    I have 3 worksheets with information for all offices for each Month Dec, Jan, Feb. I need to copy rows from each one of those worksheets and paste it to a worksheet titled PROC. Rows should be copied based upon the Processor they are assigned to in cell D.

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    Can you give a description or attach an example of what the Proc sheet should like? If you're wanting the entire rows copied, then Proc would just end up being a combination of all rows in Dec, Jan, and Feb, so I don't know what you mean by "copied based upon the Processor they are assigned to".

  3. #3
    Registered User
    Join Date
    01-11-2013
    Location
    Wichita, KS
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    I want to take all rows from Dec, Jan, Feb worksheets A1 to Bf1(could be more if I add more rows)and copy those to PRC worksheet and sort by column D (Processor. Then I need to insert a row to separate (Fill Black) so that I can paste rows A1 to Bf1 if they have "Setup, Needs, Conditions, Submitted, Resubmitted" in column BC sorting again by column D Processor and column BC. Example of what I want it to look like on example worksheetAttachment 285163

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    This should get you a start. Be sure you have headings on PROC before running it.
    Option Explicit
    Dim ws As Worksheet, rw As Long, prw As Long
    
    Sub MoveData()
        Application.ScreenUpdating = False
        Sheets("PROC").Select
        prw = Cells(Rows.Count, 4).End(xlUp).Row
    
        ' Clear previous values
        If prw > 1 Then
            Rows("2:" & prw).Delete
        End If
        prw = 2
    
         ' Process sheets with 3-character names
        For Each ws In ActiveWorkbook.Worksheets
            With ws
                If Len(.Name) = 3 Then
                    rw = .Cells(.Rows.Count, 4).End(xlUp).Row
                    .Rows("2:" & rw).Copy Destination:=Cells(prw, 1)
                    prw = prw + rw - 1
                End If
            End With
        Next
    
        ' Sort by Processor
        prw = Cells(Rows.Count, 4).End(xlUp).Row
        With ActiveSheet.Sort
            .SortFields.Clear
            .SortFields.Add Key:=Range("D2"), Order:=xlAscending
            .SetRange Range("A2:AB" & prw)
            .Header = xlNo
            .Orientation = xlTopToBottom
            .Apply
        End With
    
        ' Delete blank rows, if any
        rw = Cells(Rows.Count, 4).End(xlUp).Row + 1
        If prw > rw Then
            Rows(rw & ":" & prw).Delete
        End If
    
        ' Add blank rows
        prw = 3
        Do Until Cells(prw, 4).Value = ""
            If Cells(prw, 4).Value <> Cells(prw - 1, 4).Value Then
                Rows(prw).Insert
                Rows(prw).Interior.Color = 1
                prw = prw + 1
            End If
            prw = prw + 1
        Loop
    End Sub

  5. #5
    Registered User
    Join Date
    01-11-2013
    Location
    Wichita, KS
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    I created a command active x button and pasted the code, I receive a compile error

  6. #6
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    It worked when I ran it on your sample workbook, so you'll need to provide more info. What line did it break on, and what was the problem?

  7. #7
    Registered User
    Join Date
    01-11-2013
    Location
    Wichita, KS
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    Can you send me the sample workbook back so I can see it?

  8. #8
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    Here it is, but please look at my private message to you regarding this workbook, if you haven't already seen it.
    Last edited by natefarm; 12-20-2013 at 10:19 AM.

  9. #9
    Registered User
    Join Date
    01-11-2013
    Location
    Wichita, KS
    MS-Off Ver
    Excel 2013
    Posts
    25

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    Thanks for the private message... I sent u a couple After I downloaded the example I was unable to see the button you added?

  10. #10
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Copy Rows to Existing Worksheet Based upon a Cell Value

    Oh, I didn't add a button. I was just running the code. You can add one and assign it to to the subroutine.

+ 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] Copy rows from one worksheet to another worksheet based on a cell criteria.
    By keneco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-07-2013, 10:28 AM
  2. [SOLVED] Copy rows from my main worksheet to another worksheet based on data in one cell
    By gcol in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-08-2012, 05:12 AM
  3. Copy rows into existing sheet based on the value of a cell.
    By jamesjy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2012, 05:45 PM
  4. Copy rows to new worksheet based on cell value
    By truffle6 in forum Excel General
    Replies: 1
    Last Post: 01-13-2009, 01:40 PM
  5. copy rows to a new worksheet based on cell value
    By Dan Howard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2006, 03:37 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