Macro/VBA suggestion needed

Flora2021

New Member
Joined
Apr 28, 2022
Messages
44
Office Version
  1. 365
Platform
  1. Windows
Hello, I have a spreadsheet (sheet1)that we need to print for approximately 90 employees. On this sheet there is a name, 3 different department fields, and a date range field.
I have another sheet (Sheet2) that lists all of this data in separate columns. I would like to be able to copy and paste each of the columns into the fields on sheet one and then print and repeat. I know I can create a macro to do this function, but I don't want to repeat it each time for 90 people. Is there a way to make it look at next row and repeat the steps?
 

Attachments

  • TR1.PNG
    TR1.PNG
    8 KB · Views: 7
  • TR2.PNG
    TR2.PNG
    16.3 KB · Views: 8
Just a slight modification to @Puertorekinsam's Post #7 should get you there:

VBA Code:
Sub fill_and_print()
    Dim i As Long, j As Long
    i = 2
    Do Until Sheet2.Cells(i, 1) = ""
        For j = 1 To 5
            Sheet1.Cells(j + 1, 2) = Sheet2.Cells(i, j)
        Next
       
        Sheet1.PrintOut
        i = i + 1
    Loop
End Sub
the merged cells is a problem, the training data is dropping in column C not B like the rest. So that's why I cut the for loop down to 4 and doubled the copy over line (just shifted one to the right)

Code:
Sub fill_and_print()
    Dim i As Long, j As Long
    i = 2
    Do Until Sheet2.Cells(i, 1) = ""
        For j = 1 To 4
            Sheet1.Cells(j + 1, 2) = Sheet2.Cells(i, j)
        Next
            Sheet1.Cells(j + 1, 2+1) = Sheet2.Cells(i, j)
       
        Sheet1.PrintOut
        i = i + 1
    Loop
End Sub
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Good spot, I hadn't noticed that training was 1 column over from the others.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,873
Members
449,130
Latest member
lolasmith

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top