AW: Neuen Datensatz einfügen über VBA
19.11.2014 11:46:26
Werner
Hallo Tom,
so?
Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, cancel As Boolean)
Dim zeilenanzahl As Long
Dim x As Integer
Dim i As Integer
x = 1
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If target.Column = 1 Then
On Error GoTo Notausgang
zeilenanzahl = 1
With ActiveCell
For i = 1 To zeilenanzahl
If ActiveCell = "" Then
.Value = Date
.EntireRow.Copy
.EntireRow.Offset(x, 0).Insert shift:=xlDown
.EntireRow.Offset(x, 0).PasteSpecial
.EntireRow.Offset(x, 0).SpecialCells(xlCellTypeConstants).ClearContents
Else
.EntireRow.Copy
.EntireRow.Offset(x, 0).Insert shift:=xlDown
.EntireRow.Offset(x, 0).PasteSpecial
.EntireRow.Offset(x, 0).SpecialCells(xlCellTypeConstants).ClearContents
ActiveCell.Offset(-x, 0).Select
.Value = Date
End If
x = x + 1
Next i
.Offset(1, 0).Select
End With
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Notausgang:
cancel = True
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Exit Sub
End If
End Sub
Gruß Werner