How can I set this for multiple pages? It works now only for one page on the sheet it must be two pages
Dim Rng As String
Dim wks As Worksheet
Dim sh As Worksheet
Dim Arr() As String
Dim N As Integer
Dim ws As Worksheet
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = True And sh.Range("M1").Value = "ja" Then
With sh.PageSetup
On Error Resume Next
lnglastrow = 10
lnglastrow = Application.Evaluate("=MAX(IF(A1:N299<>"""",ROW(A1:N299),10))") 'laatst gebruikte rij voor kolommen A tot N en kijken tot rij 1000
On Error GoTo 0
.PrintArea = "$A$2:$N$" & lnglastrow
.FitToPagesWide = 1
.FitToPagesTall = 1
'sh.PrintPreview
End With
End If
Next
N = 0
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = xlSheetVisible And sh.Range("M1").Value = "ja" Then
N = N + 1
ReDim Preserve Arr(1 To N)
Arr(N) = sh.Name
End If
Next
If N = 0 Then MsgBox "niets te printen": Exit Sub
With ActiveWorkbook
.Worksheets(Arr).PrintPreview
End With
End Sub
And you don't know how to do that? Is that the case? From your macro I'd have thought that you did know how to do that ..... or am I misunderstanding something?
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.