Dim wks As Worksheet
Dim Bereich As Range
Set wks = ActiveSheet
With wks
Set Bereich = .Range(.Cells(5, 5), _
.Cells(.Cells.SpecialCells(xlCellTypeLastCell).Row, _
.Cells.SpecialCells(xlCellTypeLastCell).Column))
MsgBox "Der benutzte Bereich liegt in: " & Bereich.Address
Bereich.Copy Workbooks("Test.xls").Worksheets("Tabelle1").Cells(5, 5)
End With
Set wks = Nothing
Set Bereich = Nothing
Sub kopierebereich()
Dim wks As Worksheet
Dim Bereich As Range
Set wks = ActiveSheet
With wks
Set Bereich = .Range(.Cells(5, 5), _
.Cells(.Cells.SpecialCells(xlCellTypeLastCell).row, _
.Cells.SpecialCells(xlCellTypeLastCell).Column))
MsgBox "Der benutzte Bereich liegt in: " & Bereich.Address
Bereich.Copy Workbooks("Test.xls").Sheets(1).Cells(5, 1)
Sheets(1).Activate
End With
Set wks = Nothing
Set Bereich = Nothing
' With ActiveSheet
' Application.ScreenUpdating = False
' Tmp = Cells.Find("*", [A1], , , xlByRows, xlPrevious).row
' For x = Tmp To 1 Step -1
' Do While Application.CountA(Rows(x)) = False
' Rows(x).EntireRow.Delete
' Loop
' Next x
'End With
End Sub
Die kommentierten Zeilen sollten eigentlich dafür sorgen dass nach dem kopiervorgangSub kopierebereich()
Dim wks As Worksheet
Dim Bereich As Range
Set wks = ActiveSheet
Dim Zeile As Long
Dim ZeileMax As Long
With wks
Set Bereich = .Range(.Cells(5, 5), _
.Cells(.Cells.SpecialCells(xlCellTypeLastCell).row, _
.Cells.SpecialCells(xlCellTypeLastCell).Column))
MsgBox "Der benutzte Bereich liegt in: " & Bereich.Address
Bereich.Copy Workbooks("Test.xls").Sheets(1).Cells(5, 1)
Sheets(1).Activate
End With
Set wks = Nothing
Set Bereich = Nothing
Workbooks("Test.xls").Worksheets("Sheet1").Activate
ZeileMax = ActiveSheet.UsedRange.Rows.Count
For Zeile = ZeileMax To 1 Step -1
If Application.WorksheetFunction.CountA(Rows(Zeile)) = 0 Then
Rows(Zeile).Delete
End If
Next Zeile
End Sub
Sheet1 ist vorher leer hat jedoch eine bestimmte formatierung Zeilen und Spaltenbreite, damit man den kopierten bereich auch sehen kann und die texte nicht durcheinander sindSub kopierebereich()
Dim wks As Worksheet
Dim Bereich As Range
Dim Zeile As Long
Dim ZeileMax As Long
Set wks = ActiveSheet
With wks
Set Bereich = .Range(.Cells(5, 5), _
.Cells(.Cells.SpecialCells(xlCellTypeLastCell).Row, _
.Cells.SpecialCells(xlCellTypeLastCell).Column))
MsgBox "Der benutzte Bereich liegt in: " & Bereich.Address
Bereich.Copy Workbooks("Mappe3").Sheets(1).Cells(5, 1)
End With
Set wks = Nothing
Set Bereich = Nothing
Workbooks("Mappe3").Worksheets(1).Activate
ZeileMax = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
For Zeile = ZeileMax To 1 Step -1
If Application.WorksheetFunction.CountA(Rows(Zeile)) = 0 Then
Rows(Zeile).Delete
End If
Next Zeile
End Sub
Sub kopierebereich()
Dim wks As Worksheet
Dim Bereich As Range
Dim Zeile As Long
Dim ZeileMax As Long
Set wks = ActiveSheet
With wks
Set Bereich = .Range(.Cells(5, 5), _
.Cells(.Cells.SpecialCells(xlCellTypeLastCell).Row, _
.Cells.SpecialCells(xlCellTypeLastCell).Column))
MsgBox "Der benutzte Bereich liegt in: " & Bereich.Address
Bereich.Copy Workbooks("Mappe3").Sheets(1).Cells(5, 1)
End With
Set wks = Nothing
Set Bereich = Nothing
With Workbooks("Mappe3").Worksheets(1)
ZeileMax = .UsedRange.SpecialCells(xlCellTypeLastCell).Row
For Zeile = ZeileMax To 1 Step -1
If Application.WorksheetFunction.CountA(.Rows(Zeile)) = 0 Then
.Rows(Zeile).Delete
End If
Next Zeile
End With
End Sub
If Application.WorksheetFunction.CountA(Union(.Cells(Zeile, _
1), .Range(.Cells(Zeile, 3), .Cells(Zeile, 6)))) = 0 Then
.Rows(Zeile).Delete
End If