Johniny

Autoprinter

Jan 17th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Autoprinter()
  2.  
  3. ' This macro is supposed to copy cells starting
  4. ' from G2 to G2+i until it encounters empty cell to output cell A2
  5. ' and print. Rinse and repeat.
  6.  
  7.  
  8. Dim i As Long
  9. i = 2
  10.     Do While Not IsEmpty(Range("G" & i))
  11.     ' should continue until it meets empty cell
  12.    Range("G" & i).Select
  13.     Selection.Copy
  14.     Range("A2").Select
  15.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  16.         :=False, Transpose:=False 'Operation, SkipBlanks and Transpose could be ommited & xlPasteValues could be changed for xlPasteValuesAndNumberFormats
  17. 'https://docs.microsoft.com/en-us/office/vba/api/excel.xlpastetype
  18.    Application.CutCopyMode = False
  19.     ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
  20.         IgnorePrintAreas:=False
  21.     ' print, just from macro recorder, could be useful to rewrite
  22.    i = i + 1
  23.     ' looping row number
  24.    Loop
  25.    
  26. End Sub
Add Comment
Please, Sign In to add comment