Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Set ws data = Workbooks("test_dteztz.xlsx").Worksheets("EE Upload")
[b]Function RangeName(sName As String) As String
RangeName = Application.Substitute(sName, " ", "_")
End Function
[/b]Sub MergePrint()
'set up your merge form by naming the merge fields _
with the same name as the data fields you are importing.
'if any data field contains spaces, then substitute an _
UNDERSCORE character for each space in the name.
Dim wsForm As Worksheet, wsData As Worksheet
Dim sRngName As String, r As Long, c As Integer
Set wsForm = Worksheets("My Form") 'change to your sheet name
Set wsData = Worksheets("My Data") 'change to your sheet name
With wsData.Cells(1, 1).CurrentRegion
For r = 2 To .Rows.Count
If Not wsData.Cells(r, 1).EntireRow.Hidden Then
For c = 1 To .Columns.Count
sRngName = wsData.Cells(1, c).Value
Range(RangeName(sRngName)).Value = wsData.Cells(r, c)
Next
wsForm.PrintOut
End If
Next
End With
End Sub
'
With wsdata.Cells(1, 1).CurrentRegion
For r = 2 To .Rows.Count
If Not wsdata.Cells(r, 1).EntireRow.Hidden Then
For c = 1 To .Columns.Count
srngname = wsdata.Cells(1, c).Value
[highlight #FCE94F]Range(RangeName(srngname)).Value = wsdata.Cells(r, c[b]).Value[/b]
[/highlight] Next
wsform.PrintOut
End If
Next
End With
'
For c = [highlight #FCE94F]2[/highlight] To .Columns.Count
srngname = wsdata.Cells(1, c).Value
Range(RangeName(srngname)).Value = wsdata.Cells(r, c).Value
Next