0

I am not yet familiar with the VBA programming language and so far I can record and understand the macros, but making it myself is still quite difficult.

I am currently working on a print template (worksheetname "Horizontal"). The template must be filled with information which it receives from the worksheet "ZFA". After the template is filled it will print and empty it and delete the row from "ZFA". As I have to do this task many times a day I wanted to know if there is a possiblity to do this via a loop. So repeat the upper steps until column c is empty in the worksheet "ZFA".

The code I'm now using for filling in the template, printing and deleting the row is:

Range("A2").Formula2R1C1 = "=ZFA!RC"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False
Range("A2").Select
Selection.ClearContents
Sheets("ZFA").Select
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Sheets("Horizontal").Select

So is it possible to repeat this task until column C in the worksheet ZFA is empty?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 2
    You can loop through cells, row and/or columns. [This](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) and [this](https://stackoverflow.com/questions/17896655/for-loop-in-excel-vba) should prove useful to get you started – cybernetic.nomad Jan 06 '20 at 20:07
  • 1
    Another useful question: [how to find the last row](https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-excel-with-vba). – BigBen Jan 06 '20 at 20:14
  • @cybernetic.nomad Thank you so much for the articles the last one really helped me. – Wouter Groeneweg Jan 06 '20 at 20:26
  • If you find answers in those links useful, feel free to vote them up – cybernetic.nomad Jan 06 '20 at 20:47

0 Answers0