AW: Werte dynamisch in andere Tabelle übertragen
04.07.2008 15:31:43
fcs
Hallo Holger,
das folgende Makro überträgt den Inhalt des Eingabeblatts in das Statistikblatt.
Gruß
Franz
Sub EingabeUebertragen()
Dim wksEingabe As Worksheet, intI As Integer
Dim wksZiel As Worksheet, ZeileZiel As Long
Dim Spieltag As Long
Dim Heimtore As Long
Dim Gasttore As Long
Const Zeile1Ein As Long = 6 '1. Zeile im Eingabeblatt mit Torschütze
Const SpalteEinGast As Long = 7 'Spalte mit Torschützen Gast
Const SpalteEinHeim As Long = 2 'Spalte mit Torschützen Heim
If MsgBox("Eingaben nach Statistik übertragen?", vbQuestion + vbYesNo) = vbYes Then
Set wksEingabe = Worksheets("Tabelle1")
Set wksZiel = Worksheets("Tabelle2")
With wksEingabe
Heimtore = .Cells(3, 4).Value
Gasttore = .Cells(3, 9).Value
Spieltag = .Cells(3, 2).Value
End With
With wksZiel
'Letzte ausgefüllte zeile im Zielblatt Spalte A
ZeileZiel = .Cells(.Rows.Count, 1).End(xlUp).Row
'Torschützen Heim eintragen
For intI = 1 To Heimtore
ZeileZiel = ZeileZiel + 1
.Cells(ZeileZiel, 1) = Spieltag
.Cells(ZeileZiel, 2).Value = wksEingabe.Cells(Zeile1Ein + intI - 1, SpalteEinHeim). _
Value
.Cells(ZeileZiel, 3).Value = wksEingabe.Cells(Zeile1Ein + intI - 1, SpalteEinHeim + 1). _
Value
Next
'Torschützen Gast eintragen
For intI = 1 To Gasttore
ZeileZiel = ZeileZiel + 1
.Cells(ZeileZiel, 1) = Spieltag
.Cells(ZeileZiel, 2).Value = wksEingabe.Cells(Zeile1Ein + intI - 1, SpalteEinGast). _
Value
.Cells(ZeileZiel, 4).Value = wksEingabe.Cells(Zeile1Ein + intI - 1, SpalteEinGast + 1). _
Value
Next
End With
End If
End Sub