Function RangeName(sName As String) As String
RangeName = Application.Substitute(sName, " ", "_")
End Function
Sub MergePrint()
Dim wsForm As Worksheet, wsData As Worksheet
Dim sRngName As String, r As Long, c As Integer
Set wsData = Workbooks("Total Compensation Summary_dteztz.xlsx").Worksheets("EE Upload")
With wsData.Cells(1, 1).CurrentRegion
For r = 2 To .Rows.Count
If Not wsData.Cells(r, 1).EntireRow.Hidden Then
For c = 2 To .Columns.Count
sRngName = wsData.Cells(1, c).Value
Range(RangeName(sRngName)).Value = wsData.Cells(r, c).Value
Next
wsForm.PrintOut
End If
Next
End With
End Sub