Can EXCEL realize the mail merge function similar to a WORD? Is made from an EXCEL spreadsheet template, and the other an EXCEL spreadsheet data source, According to the data source automatically fill in N EXCEL spreadsheets,
Extracted from information list each record information (name, gender, birth date, join into the class and the monthly pension, the adjustment, adjusted pensions) on the corresponding position of the stamp, and automatically generate named after the name of the individual form
CodePudding user response:
Sub X () Dim dataBook As Workbook Dim dataSheet As Worksheet Dim personBook As Workbook Dim personSheet As Worksheet Dim r As Long Dim strName As String
The Set dataBook=Workbooks. Open (" data source. XLS ") The Set dataSheet=dataBook. Sheets (1)
For r=2 To dataSheet. UsedRange. Rows. Count StrName=dataSheet. Cells (r, 1). The Value
The Set personBook=Workbooks. The Add (" template. XLT ") The Set personSheet=personBook. Sheets (1) 'fill the dataSheet first r row personSheet position for'
PersonBook. SaveAs strName & amp; ". XLS "
The Set personSheet=Nothing PersonBook. Close The Set personBook=Nothing Next
The Set dataSheet=Nothing DataBook. Close The Set dataBook=Nothing End Sub
Is probably like this above, their combined with complete directory, their perfect annotation part,