Loop the macro with refresh of an input cell

EvdM

New Member
Joined
Dec 2, 2020
Messages
24
Office Version
  1. 365
Platform
  1. Windows
Dear VBA Specialists,

I've created a macro that can take a part of the sheet (A1:G33) and print it as a .pdf file (see code below)
All the information/details are filled in based on one cell (L16).
I got another sheet called "RL-Liste" which contains all the numbers that have to be filled in into L16.

Can someone help me to create a loop that runs the macro with L16 filled in with the input of A1 from sheet "RL-Liste" then A2, A3 etc... Untill it hits a blank and it has to stop.

Thanks in advance,
Edwin van der Mijl

VBA Code:
Sub Button1_Click()

Dim DateiName As String
DateiName = Range("Q4") & Range("Q3") & ".pdf"

Range("A1:G33").ExportAsFixedFormat Type:=xlTypePDF, Filename:=DateiName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True


End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Is this what you want?? :
VBA Code:
Sub test()
Dim DateiName As String

With Worksheets("RL-Liste")
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
RLIST = .Range(.Cells(1, 1), .Cells(lastrow, 1))
End With

For i = 1 To lastrow
Range("L16:L16") = RLIST(i, 1)
DateiName = Range("Q4") & Range("Q3") & ".pdf"

Range("A1:G33").ExportAsFixedFormat Type:=xlTypePDF, Filename:=DateiName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Next i



End Sub
 
Upvote 0
Solution
Thank you very much Offthelip!
That was exactly what I needed.
 
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,345
Members
449,220
Latest member
Edwin_SVRZ

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