Sperre einbauen
08.06.2005 08:32:50
Richard
ich brauche eure Hilfe, ich hab nämlich folgenden Code, er fügt die Spalten N1 und O1 hinzu, danach werden die Spalten L+M verbunden, dann werden die Werte gezählt und in der Tabelle ausgegeben. Meine Frage ist jetzt, wie kann ich eine Sperre einbauen, sodass der Anwender dies nicht zweimal macht, sonst stimmen die Spalten nicht mehr.
Wäre dankbar für eure Hilfe,
gruß
Richard
Sub SpalteDatumZeit()
Dim z As Integer
Application.ScreenUpdating = False
Columns("N:O").Select
With Selection
.Insert Shift:=xlToRight
Range("N1") = "DatumZeit"
Range("O1") = "Anzahl"
End With
With ActiveWorkbook.Worksheets(1)
z = Range("A65536").End(xlUp).Row
Range("N2").Formula = "=L2 + M2"
Range("N2").Copy Destination:=Range(Cells(2, 14), Cells(z, 14))
Columns("N:N").Select
Selection.NumberFormat = "m/d/yyyy"
Range("L2").Select
End With
Application.ScreenUpdating = True
End Sub
Sub SpalteAnzahl()
Dim nLastRow As Long
Dim rngSrc As Range
Dim rngDest As Range
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Columns("O:O").Select
With Selection
.NumberFormat = "General"
End With
'Im 1. Tabellenblatt der aktiven Arbeitsmappe, werden nun die belegten Zeilen gesucht und im
'Tabellenblatt ausgegeben.
With ActiveWorkbook.Worksheets(1)
If Application.WorksheetFunction.CountA(.Cells) > 0 Then
nLastRow = .Cells.Find(What:="*", After:=.Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
.Cells(2, 15).Value = 1 'Zelle O1
Set rngSrc = .Cells(2, 15)
Set rngDest = .Range(.Cells(2, 15), .Cells(nLastRow, 15))
rngSrc.AutoFill rngDest, xlFillSeries
Set rngSrc = Nothing
Set rngDest = Nothing
Else
MsgBox "Das Tabellenblatt enthält keine Daten!"
End If
End With
Columns("A:IM").AutoFit
Range("A1").Select
Set rngSrc = Nothing
Set rngDest = Nothing
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End
Sub