Alle Blätter erste frei Zelle zentriert aktivieren
09.01.2005 13:36:20
Beate Schmitz
Hallo Sascha,
verknüpfe deinen Button mit folgendem Makro (sucht erste freie Zelle in Spalte A, kannst du abändern) - das Makro gehört in ein Modul:
Sub erstefreie()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim blatt As Worksheet
For Each blatt In ActiveWorkbook.Worksheets
blatt.Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
CenterOnCell ActiveCell
Next blatt
'alles wieder anschalten:
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Zusätzlich muss dieses Makro (von Chip Pearson) in ein Modul kopiert werden:
Sub CenterOnCell(OnCell As Range)
Dim VisRows As Integer
Dim VisCols As Integer
Application.ScreenUpdating = False '
' Switch over to the OnCell's workbook and worksheet.'
OnCell.Parent.Parent.Activate
OnCell.Parent.Activate '
' Get the number of visible rows and columns for the active window.'
With ActiveWindow.VisibleRange
VisRows = .Rows.Count
VisCols = .Columns.Count
End With '
' Now, determine what cell we need to GOTO. The GOTO method will
' place that cell reference in the upper left corner of the screen,
' so that reference needs to be VisRows/2 above and VisCols/2 columns
' to the left of the cell we want to center on. Use the MAX function
' to ensure we're not trying to GOTO a cell in row <=0 or column <=0.'
With Application
.Goto reference:=OnCell.Parent.Cells( _
.WorksheetFunction.Max(1, OnCell.Row + _
(OnCell.Rows.Count / 2) - (VisRows / 2)), _
.WorksheetFunction.Max(1, OnCell.Column + _
(OnCell.Columns.Count / 2) - _
.WorksheetFunction.RoundDown((VisCols / 2), 0))), _
scroll:=True
End With
OnCell.Select
Application.ScreenUpdating = True
End Sub
Danach ist auf allen Blättern die erste frei Zelle aktiviert und auf halber Bildschirmhöhe sichtbar.
Gruß,
Beate