Printing multiple times with changing data

orzys

New Member
Joined
Jan 16, 2024
Messages
2
Platform
  1. Windows
Hi there, I believe this is doable with a macro loop but it has been ages since I tried anything and I don't know where to even begin.

I have file consisting of 2 sheets:
A. Table that contain various values for a few dozen projects, so that every row is a project and every column (about 20 columns) has different values for all projects.
B. Made up document with 20 empty cells designated for the data in each of those 20 columns in sheet A.

Basically I need to print sheet B multiple times (as many as the number of rows in sheet A, without the first row containing headers):
The first print will have all those 20 previously-empty cells showing all the corresponding values from the second row (first row is headers) in sheet A
The second print will have values from the third row in sheet A, and so on.

Any help is appreciated
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi there, I believe this is doable with a macro loop but it has been ages since I tried anything and I don't know where to even begin.

I have file consisting of 2 sheets:
A. Table that contain various values for a few dozen projects, so that every row is a project and every column (about 20 columns) has different values for all projects.
B. Made up document with 20 empty cells designated for the data in each of those 20 columns in sheet A.

Basically I need to print sheet B multiple times (as many as the number of rows in sheet A, without the first row containing headers):
The first print will have all those 20 previously-empty cells showing all the corresponding values from the second row (first row is headers) in sheet A
The second print will have values from the third row in sheet A, and so on.

Any help is appreciated
I managed to find the solution.

In case it helps anyone else (duplicate population and resetting for each cell required):
VBA Code:
Option Explicit

Sub IrregularForm()
Dim MyRange As Range, MyVal As Long, LR As Long


LR = Sheets("Data").Range("K" & Rows.Count).End(xlUp).Row
'Set MyRange = Sheets("Data").Range("K1:K" & LR)

    For MyVal = 2 To LR Step 1
        Sheets("Form").[B5].Value = Sheets("Data").Range("K" & MyVal).Value
        Sheets("Form").[D5].Value = Sheets("Data").Range("L" & MyVal).Value
        Sheets("Form").[G5].Value = Sheets("Data").Range("M" & MyVal).Value

        Sheets("Form").PrintOut Copies:=1
    Next MyVal

Sheets("Form").[B5].Value = ""
Sheets("Form").[D5].Value = ""
Sheets("Form").[G5].Value = ""

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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