+ Reply to Thread
Results 1 to 2 of 2

Thread: Copying rows (content & formats) to separate worksheet based on cell value

  1. #1
    Registered User
    Join Date
    01-24-2012
    Location
    Wilmington, DE
    MS-Off Ver
    Excel 2007
    Posts
    1

    Copying rows (content & formats) to separate worksheet based on cell value

    Hello,

    I am looking to automatically copy rows from the first worksheet 'Master List' into separate worksheets. The first worksheet 'Master List' contains many co-workers and who they are assigned to maintain relationships with. Based on the names of the co-workers in Column A (starting in row 16), I would like the rows to be copied into the following worksheets based on the name. For example, everytime a row is added in the 'Master List' with the name 'Childs' in column A, I would like it to be added to the worksheet named 'Childs' (starting at row 16 in the worksheet).

    Below is the worksheet. Can someone please help me figure this solution out??

    Thanks!

    Example - Tracking Report (2).xls

  2. #2
    Forum Guru
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    1,798

    Re: Copying rows (content & formats) to separate worksheet based on cell value

    Hi bobbyjay,

    Generally, I try to use an event handler to move data over to new sheets. This prevents confusion over what get's moved and what doesn't. As an example, I included a bit of code to be added to the Master worksheet module (right click on the tab name Master List, and choose view code).

    The following code activates when you double click any cell within the data subsect. It copies data to the proper sheet after the double click event. The code can be modified to accept different events. Let me know if that helps.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        Dim Crow As Long
        Dim ws As Worksheet
        Dim nm As String
        Dim lRow As Long
        
        Crow = Target.Row
        
        If Crow >= 16 Then
            Cancel = True
            nm = Cells(Crow, 1).Value
            Set ws = Sheets(nm)
            lRow = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
            
            If lrpw < 16 Then
                lRow = 16
            End If
            
            Rows(Crow).Copy ws.Cells(lRow, 1)
            
        End If
        
        
        
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0