Hi all,

I am trying to copy format and data from different worksheet.

I have no issue on copying the format from "Template" sheet but having problem copying data from other sheet matching the column once the format have been completed.

The idea is to

1 - copy format from template
2 - copy data fill in template based on column criteria

Example code

Sub SheetsFromTemplate()

Dim wsMASTER As Worksheet, wsTEMP As Worksheet, wasVISIBLE As Boolean
Dim shNAMES As Range, Nm As Range

With ThisWorkbook
    Set wsTEMP = .Sheets("Template")
    wasVISIBLE = (wsTEMP.Visible = xlSheetVisible)
    If Not wasVISIBLE Then wsTEMP.Visible = xlSheetVisible
    
    Set wsMASTER = .Sheets("Sandbox")
                                                                
    Set shNAMES = wsMASTER.Range("D4:D" & Columns.Count).SpecialCells(xlConstants)
    
    Application.ScreenUpdating = False
    For Each Nm In shNAMES
        If Not Evaluate("ISREF('" & CStr(Nm.Text) & "'!A1)") Then
            wsTEMP.Copy After:=.Sheets(.Sheets.Count)              'copy according to template
            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx                       'copy data matching column name
            ActiveSheet.Name = CStr(Nm.Text)
            
             
        End If
    Next Nm
    
    wsMASTER.Activate
    If Not wasVISIBLE Then wsTEMP.Visible = xlSheetHidden
    Application.ScreenUpdating = True
End With

End Sub
xxxxxx is where i hope to put the code so it does loop and copy the data into the newly created sheet.

Thanks in advance