wie lautet den der VBA Code, wenn ich zum Beispiel aus "Tabelle2" Spalte B2:B500 und Spalte E2:E500 in die letzte Zeile aus "Tabelle1" Spalte A und Spalte D einfügen möchte?
With ThisWorkbook.Worksheets("Tabelle1")
ThisWorkbook.Worksheets("Tabelle2").Range("B2:B500").Copy _
Destination:=.Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
ThisWorkbook.Worksheets("Tabelle2").Range("E2:E500").Copy _
Destination:=.Cells(.Rows.Count, 4).End(xlUp).Offset(1, 0)
End With
Gruess Hansueli
Private Sub CommandButton1_Click()
Dim wsQ As Worksheet
Dim lNextRow As Long
Dim lLastRow As Long
Set wsQ = ThisWorkbook.Worksheets("Bestellübersicht")
lNextRow = Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).Row ' Nächste freie Zeile aufgrund _
Spalte D
lLastRow = wsQ.Cells(wsQ.Rows.Count, 1).End(xlUp).Row ' Letzte besetzte Zeile in _
Quelle Spalte A
wsQ.Range(wsQ.Cells(2, 2), wsQ.Cells(lLastRow, 2)).Copy _
Destination:=Cells(lNextRow, 4) ' Spalte B -> D
wsQ.Range(wsQ.Cells(2, 3), wsQ.Cells(lLastRow, 3)).Copy _
Destination:=Cells(lNextRow, 5) ' Spalte C -> E
wsQ.Range(wsQ.Cells(2, 5), wsQ.Cells(lLastRow, 5)).Copy _
Destination:=Cells(lNextRow, 3) ' Spalte E -> C
Range(Cells(lNextRow, 3), Cells(lNextRow + lLastRow - 1, 3)).Replace _
What:="00.01.1900", Replacement:="31.12.2015", LookAt:= _
xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False
With ActiveSheet.ListObjects("Tabelle_Abfrage_von_NAVISION_DECK_1")
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Range( _
.Name & "[Item No_]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
.Sort.SortFields.Add Key:=Range( _
.Name & "[Due Date]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
With .Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
End Sub
Gruess Hansueli
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen