AW: Tabelle erweitern (makros)
11.07.2017 13:53:59
yummi
Hallo Dennis,
Sub a()
Dim Wb As Workbook: Set Wb = ThisWorkbook
Dim Ws As Worksheet: Set Ws = Wb.Worksheets("Tabelle1")
Dim Basis As Range, Gruppe As Range, BlockStart&
Dim a, i&, j&
Application.ScreenUpdating = False
With Ws
a = .Range("F12:F" & .Cells(Ws.Rows.Count, 6).End(xlUp).Row)
For i = LBound(a) To UBound(a)
If InStr(1, a(i, 1), "Projektleiter") Then j = j + 1
Next i
BlockStart = j * 40 + 14
If BlockStart > (.Rows.Count - 41) Then
MsgBox "Blattende. Kein weiterer Pj-Bereich möglich!"
Exit Sub
End If
Set Basis = .Range("A14:BN63")
Basis.Copy Destination:=.Cells(BlockStart + 2, 1)
Set Gruppe = .Range(.Cells(BlockStart + 4, 1), _
.Cells(BlockStart + 40, 66)) 'die 66 sagt hier das dein Bereich 66 _
spalten (1 bis 66)breit ist und 36 Zeilen tief ist (Blockstart + bis Blockstart +40
Select Gruppe 'die Zeile nur zum debuggen, damit du siehst, ob der Bereich an _
der richtigen Stelle ist, danach wieder löschen
Gruppe.Rows.Group
End With
Set Wb = Nothing: Set Ws = Nothing
Set Basis = Nothing: Set Gruppe = Nothing
Erase a
End Sub
Mit Reinziehen meine ich markiere eine Variable, linke maustaste drücken und halten und dann im Überwachungsfenster fallen lassen
Gruß
yummi