ich habe ein Makro mit dem kann man eine markierte Zeile mit ALT+Pfeiltasten hoch und runter verschieben.
Jetzt möchte ich das die gleichen Zeile auf Tabelle 5 und Tabelle 6 auch verschoben werden.
Es wäre toll wenn mir einer helfen könnte. Vielen Dank im voraus.
Gruß Nefantus
Sub moveSelection(Optional Direction As String = "up")
On Error GoTo ErrExit
Dim rng As Range, objTarget As Worksheet, objSh As Worksheet
Dim rngMove As Range
Dim lngFirst As Long, lngLast As Long, lngMove As Long, lngOld As Long, lngNew As Long
Dim intMove As Integer
On Error GoTo ErrExit
GMS
Set rng = Selection
Set objTarget = rng.Parent
lngFirst = rng.Cells(1, 1).Row
lngLast = lngFirst + rng.Rows.Count - 1
With objTarget
If LCase(Direction) = "up" Then
If lngFirst = 1 Then GoTo ErrExit
lngMove = lngFirst - 1
lngOld = lngFirst - 1
lngNew = lngLast
intMove = -1
Else
If lngLast = Rows.Count Then GoTo ErrExit
lngMove = lngFirst + 1
lngOld = lngLast + 1
lngNew = lngFirst
intMove = 1
End If
Set objSh = Worksheets.Add
.Range(.Cells(lngOld, 1), .Cells(lngOld, Columns.Count)).Copy objSh.Cells(1, 1)
Set rngMove = .Range(.Cells(lngFirst, 1), .Cells(lngLast, Columns.Count))
rngMove.Copy .Cells(lngMove, 1)
objSh.Range(objSh.Cells(1, 1), objSh.Cells(1, Columns.Count)).Copy .Cells(lngNew, 1)
objSh.Delete
rng.Offset(intMove, 0).Select
End With
ErrExit:
GMS True
Set objSh = Nothing
Set rng = Nothing
End Sub Sub moveUP()
moveSelection
End Sub
Sub moveDOWN()
moveSelection "down"
End Sub
Public Sub GMS(Optional ByVal Modus As Boolean = False)
Static lngCalc As Long
With Application
.ScreenUpdating = Modus
.EnableEvents = Modus
.DisplayAlerts = Modus
.EnableCancelKey = IIf(Modus, 1, 0)
If Not Modus Then lngCalc = .Calculation
If Modus And lngCalc = 0 Then lngCalc = -4105
.Calculation = IIf(Modus, lngCalc, -4135)
.Cursor = IIf(Modus, -4143, 2)
End With
End Sub