Feb 21 2024 12:12 PM
I have a form that I print out monthly after I make date changes. I have to print this and other forms for multiple people. The form is the same, except for their name at the top. Right now I have the form laid out for each person and I make all the changes on each page and then print.
My question is: is there a way to make the changes on one page and print and it will change the name at the top automatically? Kind of like mail merge on Word, but this is in one cell on Excel.
Does that make sense? Thanks to anyone who can understand this and help me. 🙂
Feb 21 2024 01:39 PM
If you're using the desktop version of Excel for Mac or Windows, you can run a macro.
In the following, I'll make the following assumptions:
To create the macro, follow these steps:
The code:
Sub PrintForms()
Dim FormSheet As Worksheet
Dim ListSheet As Worksheet
Dim NameRow As Long
Dim LastRow As Long
Application.ScreenUpdating = False
' The sheets to be used
Set FormSheet = Worksheets("Form")
Set ListSheet = Worksheets("List")
' The row of the last name
LastRow = ListSheet.Range("A1").End(xlDown)
' Loop through the names
For NameRow = 2 To LastRow
' Enter the next name in B1 on the form sheet
FormSheet.Range("B1").Value = ListSheet.Range("A" & NameRow).Value
' Print the form sheet
FormSheet.PrintOut
Next NameRow
Application.ScreenUpdating = True
End Sub
Feb 21 2024 02:01 PM
Feb 21 2024 02:17 PM - edited Feb 21 2024 02:17 PM
Use Option instead of Alt:
Option+F11 to activate the Visual Basic Editor
Option+F8 to activate the Macros dialog.
Change the macro as follows:
Sub PrintForms()
Dim FormSheet As Worksheet
Dim ListSheet As Worksheet
Dim NameRow As Long
Dim LastRow As Long
Application.ScreenUpdating = False
' The sheets to be used
Set FormSheet = Worksheets("Form") ' change name as needed
Set ListSheet = Worksheets("List") ' change name as needed
' The row of the last name
LastRow = ListSheet.Range("A1").End(xlDown)
' Loop through the names
For NameRow = 2 To LastRow
' Enter the next name in A1 on the form sheet
FormSheet.Range("A1").Value = ListSheet.Range("A" & NameRow).Value
' Print the form sheet
FormSheet.PrintOut
Next NameRow
Application.ScreenUpdating = True
End Sub