Zellen nicht drucken
05.06.2005 18:24:56
HW
Hallo Michaela
Druckbereich automatisch anpassen
Sub Letzte()
Dim LZeile%, LSpalte%
LZeile = RealLastCell(ActiveSheet).Row
LSpalte = RealLastCell(ActiveSheet).Column
Set druckrange = Range(Cells(1, 1), Cells(LZeile, LSpalte))
ActiveSheet.PageSetup.PrintArea = druckrange.Address
End Sub
'Funktion von John Walkenbach
Function RealLastCell(TheSheet As Worksheet) As Range
Dim ExcelLastCell As Range
Dim Row%, Col%, LastRowWithData%, LastColWithData%
Application.ScreenUpdating = False
Set ExcelLastCell = TheSheet.Cells.SpecialCells(xlLastCell)
LastRowWithData = ExcelLastCell.Row
Row = ExcelLastCell.Row
Do While Application.CountA(TheSheet.Rows(Row)) = 0 And Row <> 1
Row = Row - 1
Loop
LastRowWithData = Row
LastColWithData = ExcelLastCell.Column
Col = ExcelLastCell.Column
Do While Application.CountA(TheSheet.Columns(Col)) = 0 And Col <> 1
Col = Col - 1
Loop
LastColWithData = Col
Set RealLastCell = TheSheet.Cells(Row, Col)
End Function
Tschüs H.W