• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Mapping cells to another worksheet

Sotongli

New Member
Hi All,

I need some help to finish a VBA code for the output i need.

Two tables need to be partially merged into one. The values, format and comments of filled cells in the 'status' workbook must be copied into the 'update' workbook under the same ID (which is a unique identifier) and column. The output produced by this macro is supposed to be looking like the workbook "ViewOutput".

It seems my code is not mapping the filled cells using the ID.

Please find the attached sample data file for your reference.

Thank you for your help and assistance.


Code:
Sub test1()
' Move cells with comments to target workbook

    Dim i As Integer
    Dim lngLetzteZeile As Long
    Dim lngZielZeile As Long
    Dim wksQ As Worksheet
    Dim wksZ As Worksheet
    Set wksQ = ActiveWorkbook.Worksheets("status") ' Source Workbook
    Set wksZ = ActiveWorkbook.Worksheets("update") ' Target Workbook
    
    lngLetzteZeile = wksZ.Cells(Rows.Count, 1).End(xlUp).Row
    For lngZielZeile = 3 To lngLetzteZeile
        For i = 5 To 11
            If wksQ.Cells(lngZielZeile + 1, i).Interior.ColorIndex <> 2 Then
                  wksQ.Cells(lngZielZeile, i).copy Destination:=wksZ.Cells(lngZielZeile + 1, i)
            End If
        Next i
    Next lngZielZeile
End Sub
 

Attachments

  • Mapping.xlsm
    49.2 KB · Views: 6
Back
Top