Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao andyfas,
Prova qualcosa del genere:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim LRow As Long
Set WB = ThisWorkbook
Set SH = WB.Sheets("Foglio1") '<<==== Modifica
With SH
LRow = LastRow(SH, .Columns("A:A"))
Set Rng = .Range("A1:M" & LRow)
End With
SH.PageSetup.PrintArea = Rng.Address
End Sub
'--------->>
Public Function LastRow(SH As Worksheet, _
Optional Rng As Range)
If Rng Is Nothing Then
Set Rng = SH.Cells
End If
On Error Resume Next
LastRow = Rng.Find(What:="*", _
after:=Rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
'<<=========
Se dovresti comunque avere un problema, spiega come l'area di stampa deve essere determinata e posterò una revisione del codice.
===
Regards,
Norman