Consulting

Results 1 to 3 of 3

Thread: Macro To copy and paste data from a list to corresponding worksheet and cells

  1. #1

    Macro To copy and paste data from a list to corresponding worksheet and cells

    Hello,

    In the attached workbook, I am looking for VBA that would copy the data from column E on the Activities wksheet and paste as values matching Column B (Date) and Column G (name) to the appropriate named wksheet (Group) and matching date and name.

    The complete list of Groups and Names are in columns I & J for reference.

    I hope I have explained it sufficiently.

    Thank you in advance for any assistance,

    BigDawg15

    2017 Work Activity Schedule v1 - Copy.xlsm
    Last edited by BigDawg15; 08-24-2017 at 08:27 AM. Reason: Clarify

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Option Explicit
    
    
    Sub Test()
        Dim r As Range, cel As Range, Ws As Worksheet
        Dim Rw&, Col&, Grp$, Nm$
        With Sheets("Activities")
            Set r = Range(.Cells(2, 5), .Cells(Rows.Count, 5).End(xlUp))
        End With
        For Each cel In r
            If Len(cel) > 3 Then
            Grp = Replace(cel.Offset(, 1), "'", "")
            Set Ws = Worksheets(Grp)
            Col = Ws.Rows(1).Find(cel.Offset(, -3)).Column
            Nm = Replace(cel.Offset(, 2), "'", "")
            Rw = Ws.Columns(2).Cells.Find(Nm, lookat:=xlWhole).Row
            Ws.Cells(Rw, Col).Value = cel.Value
            Ws.Cells(Rw, Col).Interior.ColorIndex = 8  ' Can be deleted
            End If
        Next cel
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    mdmackillop,

    Absolutely awesome!!

    Thank you so much for your help.

    Have a great day,

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •