+ Reply to Thread
Results 1 to 10 of 10

Help with Macro to Copy/Paste cells to different worksheet based on Value

Hybrid View

BehrBrew Help with Macro to Copy/Paste... 08-10-2013, 12:27 PM
jaslake Re: Help with Macro to... 08-10-2013, 12:45 PM
BehrBrew Re: Help with Macro to... 08-10-2013, 01:26 PM
jaslake Re: Help with Macro to... 08-11-2013, 11:32 AM
BehrBrew Re: Help with Macro to... 08-11-2013, 11:55 AM
jaslake Re: Help with Macro to... 08-11-2013, 02:05 PM
MaryCW Re: Help with Macro to... 11-25-2013, 06:13 AM
MaryCW Re: Help with Macro to... 11-25-2013, 06:19 AM
MaryCW Re: Help with Macro to... 11-25-2013, 06:19 AM
arlu1201 Re: Help with Macro to... 11-25-2013, 06:41 AM
  1. #1
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Help with Macro to Copy/Paste cells to different worksheet based on Value

    Hi BehrBrew

    Will the Data in Master ALWAYS be new Data (Data that's not been previously transfered)?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  2. #2
    Registered User
    Join Date
    01-25-2012
    Location
    Berkeley, Ca
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Help with Macro to Copy/Paste cells to different worksheet based on Value

    Jaslake,

    Yes. That will be the most current data. The only history will be on the individual tabs. If it is easier to set up a running data page that contains the entire history, that would be okay. I would just need to set a page for the current results for the the group supervisor.

    Thanks for your help.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Help with Macro to Copy/Paste cells to different worksheet based on Value

    Hi BehrBrew

    I've added two Modules to your Sample Workbook and an additional Worksheet named "Template".

    In order for the Code in Module Transfer to function properly the Formulas in the Individual Player sheets in Range("B3:F33") need to be cleared. This Code does that
    Option Explicit
    
    Sub Clear_Stuff()
        Dim ws As Worksheet
        Dim rng As Range
    
        For Each ws In ThisWorkbook.Worksheets
            If Not ws.Name = "MASTER" And Not ws.Name = "HIGH" And Not ws.Name = "AVERAGE" _
                    And Not ws.Name = "LOW" And Not ws.Name = "Template" Then
                With ws
                    Set rng = .Range("B3:F33")
                    rng.ClearContents
                End With
            End If
        Next ws
    End Sub
    The Code in Module Transfer is the Code that distributes the Master Records to the Individual Player sheets. The Code will add a new Worksheet for any new Player if the Individual Player sheet does not already exist. You'll receive a message that the New Player Sheet has been added. This Code runs from a Button on Master sheet.
    Option Explicit
    
    Sub Transfer_Data()
        Dim ws As Worksheet
        Dim rng As Range, cel As Range, myCell As String
        Dim LR As Long
        Dim NR1 As Long
    
        Set ws = Sheets("Master")
        With ws
            LR = .Cells(5, 2).End(xlDown).Row
            For Each cel In .Range("B5:B" & LR)
                
                 If Not WorksheetExists(cel.Text) Then
                    Worksheets.Add(Before:=Worksheets("HIGH")).Name = cel.Text
                    Sheets("Template").Cells.Copy
                    Sheets(cel.Text).Range("A1").PasteSpecial
                    Application.CutCopyMode = False
                    
                    MsgBox cel.Text & " has been added"
                    
                    Sheets(cel.Text).Range("B1").Value = cel.Text
                 End If
                    With Sheets(cel.Text)
                        Set rng = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp))
                        myCell = rng.Find("Last", , xlValues, xlWhole, xlByRows, xlNext, False).Offset(-2, 0).Address
    
                        NR1 = .Range(myCell).End(xlUp).Row + 1
                        .Cells(NR1, "B").Resize(1, 5).Value = cel.Offset(0, 1).Resize(1, 5).Value
    
                    End With
            Next cel
        End With
    End Sub
    
    
    Function WorksheetExists(SheetName As String, _
            Optional WhichBook As Workbook) As Boolean
    'from Chip Pearson
        Dim WB As Workbook
        Set WB = IIf(WhichBook Is Nothing, ThisWorkbook, WhichBook)
        On Error Resume Next
        WorksheetExists = CBool(Len(WB.Worksheets(SheetName).Name) > 0)
    End Function
    I've not monkeyed with Cells B34 to G39 in the Individual Player Sheets...only you know what these are to do. Of course, try the Code n the Sample file and/or a COPY of your live file. Let me know of issues.
    Attached Files Attached Files

+ 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] Trying to copy and paste certain cells from one worksheet to another using a macro
    By renec in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-26-2013, 11:55 PM
  2. [SOLVED] Macro - Copy and Combine values in cell and paste it in other cells based on Unique ID
    By haleakala17 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2012, 05:41 PM
  3. Excel Macro to insert two rows based on condition and copy and paste multiple cells
    By mannabhalo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2012, 12:56 PM
  4. Copy Paste cells into a new sheet based on criteria macro
    By Clessie1919 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-19-2012, 02:43 AM
  5. Macro for WS/WB comparisons, and copy/paste two cells based on matches
    By adilley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2011, 10:46 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