Witam.
Czy jest możliwe przerobienie kodu tak ażeby nie wybierał (select) ostatniej celi?
Cells(LastNummer, 9).Select
Set LastCel = Selection
Sub MPIndex_PrintArea()
Application.ScreenUpdating = False
Dim LastNummer As Integer
Dim LastCel As Range
LastNummer = Last(ActiveSheet.Columns("C:C"))
Cells(LastNummer, 9).Select
Application.ScreenUpdating = False
Set LastCel = Selection
ActiveSheet.PageSetup.PrintArea = "$B$2:" & LastCel.Address
End Sub
funkcja last:
Function Last(rng As Excel.Range) As Long
On Error Resume Next
Last = rng.Find(What:="*", _
After:=rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function |