I have a Calc Project with different sheets. In Sheet1 information is writen and in Sheet2, this information is distributed to different cells, ready to print.
I want to create a macro that looks for the value of cell B15 /sheet2/ and prints that many copies of page 1 (page 1 is cells A1:F49 /sheet 2/ ). Then I want it to look for the value of cell B64 /sheet2/ and print that many copies of page 2 (page 2 is cells A50:F98 /sheet2/ ), ect./there are 35 pages total/
I created a macro for test purposes, with one sheet only. The problem with it is that it prints ONLY the second range of cells (page 2) and it prints it B15 + B64 times. For example B15 = 2, B64 = 1. Page 1 /A1:F49/ doesn’t print at all, Page 2 /A50:F98/ is printed 3 times.
Can you give me any suggestions on what to change and how to make it happen /if it’s even possible/
This is my code:
Sub PrintCopies() Dim iCopiesPage1 As Integer Dim jCopiesPage2 As Integer Dim oSheet As Object Set oSheet = ThisComponent.Sheets(0) iCopiesPage1 = oSheet.getCellRangeByName("B15").getValue() If IsNumeric(iCopiesPage1) And iCopiesPage1 > 0 Then oSheet.PrintAreas = Array(oSheet.getCellRangeByName("A1:F49").RangeAddress) For i = 1 To iCopiesPage1 ThisComponent.print(Array()) Next i Else MsgBox "Please enter a numeric value greater than 0 in cell B15" End If jCopiesPage2 = oSheet.getCellRangeByName("B64").getValue() If IsNumeric(jCopiesPage2) And jCopiesPage2 > 0 Then oSheet.PrintAreas = Array(oSheet.getCellRangeByName("A50:F98").RangeAddress) For j = 1 To jCopiesPage2 ThisComponent.print(Array()) Next j Else MsgBox "Please enter a numeric value greater than 0 in cell B64" End If End Sub
Thank you in advance!