AW: Bereich löschen password
22.07.2006 23:11:14
Erich
Hallo nochmal,
sollte die Gesamtliste nicht besser auch geschützt werden?
Option Explicit
Sub Uebertragen()
Dim wsTag As Worksheet, wsGesamt As Worksheet, lngAnz As Long
Set wsTag = ActiveSheet
Set wsGesamt = Workbooks("Gesamtmappe.xls").Sheets("Gesamtliste")
lngAnz = wsTag.Cells(Rows.Count, 1).End(xlUp).Row
If lngAnz < 2 Then
MsgBox "Die Tagesliste enthält keine Daten - Ende", vbInformation
Exit Sub
ElseIf wsGesamt.Cells(Rows.Count, 1).End(xlUp).Row + lngAnz - 1 > Rows.Count Then
MsgBox "Gesamtliste bekäme mehr als " & Rows.Count & " Zeilen! - Abbruch", vbCritical
Exit Sub
End If
wsGesamt.Unprotect Password:="123"
Range(wsGesamt.Rows(2), wsGesamt.Rows(lngAnz)).Insert
Range(wsTag.Rows(2), wsTag.Rows(lngAnz)).Copy wsGesamt.Cells(2, 1)
With Range(wsGesamt.Rows(2), wsGesamt.Rows(lngAnz)).Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
wsGesamt.Protect Password:="123"
' --------------------------------------------- Leeren der Tagesliste ab Zeile 2
Application.EnableEvents = False
wsTag.Unprotect Password:="123"
Range(Rows(2), Rows(lngAnz)).ClearContents ' sollte reichen
' Range(Rows(2), Rows(Rows.Count)).ClearContents ' wenns doch nicht reicht ...
wsTag.Protect Password:="123"
Application.EnableEvents = True
Set wsTag = Nothing
Set wsGesamt = Nothing
End Sub
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort