Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1224to1228
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Hilfe bei Code

Hilfe bei Code
Thomas
Hallo Excelfreunde,
mein Beitrag ist unten raus und daher muss ich neu um Hilfe bitten.
So schaut mein Code aus aber es läuft noch nicht rund. Es sollte egal ob ich in B3 oder C3 was wähle der Bereich geleert und dann gefüllt werden.
Dies habe ich derzeitig mit einer weiteren Zelle (D3) umgesetzt den Bereich zu leeren.
Hier mal meine Mappe.
https://www.herber.de/bbs/user/76365.xls
Mein Code.
Option Explicit
Public pubBolChanged As Boolean
Public pubLngCol As Long
Public pubLngRow As Long
Private Sub Worksheet_Change(ByVal Target As Range)
If ActiveCell.Address(0, 0) = "D3" Then
Application.EnableEvents = False
Range("B5:D17").ClearContents
Application.EnableEvents = True
End If
If Target.Address = "$B$3" Then
ReadValues Target
ElseIf Target.Address = "$C$3" Then
If Target = "B" Then
ReadValues1 Target
ElseIf Target.Address = "$C$3" Then
If Target = "C" Then
ReadValues2 Target
ElseIf Target.Address = "$C$3" Then
If Target = "D" Then
ReadValues3 Target
ElseIf Target.Address = "$C$3" Then
If Target = "E" Then
ReadValues4 Target
End If
End If
End If
End If
End If
End Sub
Sub ReadValues(rngTarget As Range)
pubLngCol = WorksheetFunction.Match(rngTarget, Sheet2.Rows(3), 0)
Application.ScreenUpdating = False
Cells(5, 2) = Sheet2.Cells(4, pubLngCol)
Cells(6, 2) = Sheet2.Cells(5, pubLngCol)
Cells(7, 2) = Sheet2.Cells(6, pubLngCol)
Cells(8, 2) = Sheet2.Cells(7, pubLngCol)
Cells(9, 2) = Sheet2.Cells(8, pubLngCol)
Cells(10, 2) = Sheet2.Cells(9, pubLngCol)
Cells(11, 2) = Sheet2.Cells(10, pubLngCol)
Cells(12, 2) = Sheet2.Cells(11, pubLngCol)
Cells(13, 2) = Sheet2.Cells(12, pubLngCol)
Cells(5, 4) = Sheet2.Cells(13, pubLngCol)
Cells(6, 4) = Sheet2.Cells(14, pubLngCol)
Cells(7, 4) = Sheet2.Cells(15, pubLngCol)
Cells(8, 4) = Sheet2.Cells(16, pubLngCol)
Cells(9, 3) = Sheet2.Cells(17, pubLngCol)
Application.ScreenUpdating = True
End Sub Sub ReadValues1(rngTarget As Range)
pubLngCol = WorksheetFunction.Match(rngTarget, Sheet2.Rows(31), 0)
Application.ScreenUpdating = False
Cells(5, 2) = Sheet2.Cells(32, pubLngCol)
Cells(6, 2) = Sheet2.Cells(33, pubLngCol)
Cells(7, 2) = Sheet2.Cells(34, pubLngCol)
Cells(8, 2) = Sheet2.Cells(35, pubLngCol)
Cells(9, 2) = Sheet2.Cells(36, pubLngCol)
Cells(10, 2) = Sheet2.Cells(37, pubLngCol)
Cells(11, 2) = Sheet2.Cells(38, pubLngCol)
Cells(12, 2) = Sheet2.Cells(39, pubLngCol)
Cells(13, 2) = Sheet2.Cells(40, pubLngCol)
Cells(5, 4) = Sheet2.Cells(41, pubLngCol)
Cells(6, 4) = Sheet2.Cells(42, pubLngCol)
Cells(7, 4) = Sheet2.Cells(43, pubLngCol)
Cells(8, 4) = Sheet2.Cells(44, pubLngCol)
Cells(9, 3) = Sheet2.Cells(45, pubLngCol)
Application.ScreenUpdating = True
End Sub
Sub ReadValues2(rngTarget As Range)
pubLngCol = WorksheetFunction.Match(rngTarget, Sheet2.Rows(51), 0)
Application.ScreenUpdating = False
Cells(5, 2) = Sheet2.Cells(52, pubLngCol)
Cells(6, 2) = Sheet2.Cells(53, pubLngCol)
Cells(7, 2) = Sheet2.Cells(54, pubLngCol)
Cells(8, 2) = Sheet2.Cells(55, pubLngCol)
Cells(9, 2) = Sheet2.Cells(56, pubLngCol)
Cells(10, 2) = Sheet2.Cells(57, pubLngCol)
Cells(11, 2) = Sheet2.Cells(58, pubLngCol)
Cells(12, 2) = Sheet2.Cells(59, pubLngCol)
Cells(13, 2) = Sheet2.Cells(60, pubLngCol)
Cells(5, 4) = Sheet2.Cells(61, pubLngCol)
Cells(6, 4) = Sheet2.Cells(62, pubLngCol)
Cells(7, 4) = Sheet2.Cells(63, pubLngCol)
Cells(8, 4) = Sheet2.Cells(64, pubLngCol)
Cells(9, 3) = Sheet2.Cells(65, pubLngCol)
Application.ScreenUpdating = True
End Sub
Sub ReadValues3(rngTarget As Range)
pubLngCol = WorksheetFunction.Match(rngTarget, Sheet2.Rows(71), 0)
Application.ScreenUpdating = False
Cells(5, 2) = Sheet2.Cells(72, pubLngCol)
Cells(6, 2) = Sheet2.Cells(73, pubLngCol)
Cells(7, 2) = Sheet2.Cells(74, pubLngCol)
Cells(8, 2) = Sheet2.Cells(75, pubLngCol)
Cells(9, 2) = Sheet2.Cells(76, pubLngCol)
Cells(10, 3) = Sheet2.Cells(77, pubLngCol)
Cells(11, 3) = Sheet2.Cells(78, pubLngCol)
Cells(12, 3) = Sheet2.Cells(79, pubLngCol)
Cells(13, 3) = Sheet2.Cells(80, pubLngCol)
Cells(5, 4) = Sheet2.Cells(81, pubLngCol)
Cells(6, 4) = Sheet2.Cells(82, pubLngCol)
Cells(7, 4) = Sheet2.Cells(83, pubLngCol)
Cells(8, 4) = Sheet2.Cells(84, pubLngCol)
Cells(9, 3) = Sheet2.Cells(85, pubLngCol)
Application.ScreenUpdating = True
End Sub
Sub ReadValues4(rngTarget As Range)
pubLngCol = WorksheetFunction.Match(rngTarget, Sheet2.Rows(89), 0)
Application.ScreenUpdating = False
Cells(5, 2) = Sheet2.Cells(90, pubLngCol)
Cells(6, 2) = Sheet2.Cells(91, pubLngCol)
Cells(7, 2) = Sheet2.Cells(92, pubLngCol)
Cells(8, 2) = Sheet2.Cells(93, pubLngCol)
Cells(9, 2) = Sheet2.Cells(94, pubLngCol)
Cells(10, 2) = Sheet2.Cells(95, pubLngCol)
Cells(11, 2) = Sheet2.Cells(96, pubLngCol)
Cells(12, 2) = Sheet2.Cells(97, pubLngCol)
Cells(13, 2) = Sheet2.Cells(98, pubLngCol)
Cells(5, 4) = Sheet2.Cells(99, pubLngCol)
Cells(6, 4) = Sheet2.Cells(100, pubLngCol)
Cells(7, 4) = Sheet2.Cells(101, pubLngCol)
Cells(8, 4) = Sheet2.Cells(102, pubLngCol)
Cells(9, 3) = Sheet2.Cells(103, pubLngCol)
Application.ScreenUpdating = True
End Sub Tabelle1
 ABCDE
1         
2  Werte aus jeweiliger Spalteaus jeweiligem Bereich   
3  2009E0 
4         
5Name1      < Bereich leeren und dann füllen wenn in B3 oder C3 was passiert
6Name2       
7Name3       
8Name4       
9Name5       
10Name6       
11Name7       
12Name8       
13Name9       
14Name10       
15Name11       
16Name12       
17Name13       
18usw.       
19         

Daten, Gültigkeit
Zelle Zulassen Daten Wert1 Wert2 Leere Zellen ignorieren Zellendropdown Titel Eingabemeldung Eingabemeldung Titel Fehler Fehlermeldung
B3Liste   2009;2010;2011;2012;2013;     Wahr   Wahr          
C3Liste   A;B;C;D;E;     Wahr   Wahr          
D3Liste   0;     Wahr   Wahr          



Tabelle2
 ABCDEF
6Name3Text 3Text 4Text 5Text 6Text 7
28Name25Text 25Text 26Text 27Text 28Text 29
29Name26Text 26Text 27Text 28Text 29Text 30
30Name27Text 27Text 28Text 29Text 30Text 31
31  B       
32Name1BText B1Text B2Text B3Text B4Text B5w
33Name2BText B2Text B3Text B4Text B5hText B6
48Name17Text B17Text B18Text B19Text B20Text B21
49Name18Text B18Text B19Text B20Text B21Text B22
50Name19Text B19Text B20Text B21Text B22Text B23
51  C       
52Name 1CText C1Text C2Text C3Text C4Text C5
53Name 2CText C2Text C3Text C4Text C5Text C6
67Name 16CText C16Text C17Text C18Text C19Text C20
68Name 17CText C17Text C18Text C19Text C20Text C21
69Name 18CText C18Text C19Text C20Text C21Text C22
70Name 19CText C19Text C20Text C21Text C22Text C23
71  D       
72NameD1123   
73NameD2234   
86NameD15151617   
87NameD16161718   
88NameD17171819   
89  E       
90NameE1102030   
91NameE2203040   
109NameE20200210220   
110NameE21210220230   

verwendete Formeln
Zelle Formel Bereich
B31 =WENN(Tabelle1!$B$3=2009;"B";"") 
C31 =WENN(Tabelle1!$B$3=2010;"B";"") 
D31 =WENN(Tabelle1!$B$3=2011;"B";"") 
E31 =WENN(Tabelle1!$B$3=2012;"B";"") 
F31 =WENN(Tabelle1!$B$3=2013;"B";"") 
B51 =WENN(Tabelle1!$B$3=2009;"C";"") 
C51 =WENN(Tabelle1!$B$3=2010;"C";"") 
D51 =WENN(Tabelle1!$B$3=2011;"C";"") 
E51 =WENN(Tabelle1!$B$3=2012;"C";"") 
F51 =WENN(Tabelle1!$B$3=2013;"C";"") 
B71 =WENN(Tabelle1!$B$3=2009;"D";"") 
C71 =WENN(Tabelle1!$B$3=2010;"D";"") 
D71 =WENN(Tabelle1!$B$3=2011;"D";"") 
E71 =WENN(Tabelle1!$B$3=2012;"D";"") 
F71 =WENN(Tabelle1!$B$3=2013;"D";"") 
B89 =WENN(Tabelle1!$B$3=2009;"E";"") 
C89 =WENN(Tabelle1!$B$3=2010;"E";"") 
D89 =WENN(Tabelle1!$B$3=2011;"E";"") 
E89 =WENN(Tabelle1!$B$3=2012;"E";"") 
F89 =WENN(Tabelle1!$B$3=2013;"E";"") 

Tabellendarstellung in Foren Version 5.37


Ich hoffe es kann mir jemand helfen.
Gruß Thomas

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Hilfe bei Code
28.08.2011 12:03:21
Tino
Hallo,
die Logik warum welche Daten in welche Spalte kommen habe ich nicht verstanden.
Schau mal ob es so geht?
https://www.herber.de/bbs/user/76367.xls
Gruß Tino
AW: Hilfe bei Code
28.08.2011 12:55:32
Thomas
Hallo Tino,
dein Code liest immer die gleiche Zeile aus und schreibt sie in die gleiche Zelle. Mein Code Schreibt aber für jeden Bereich bzw. A,B,C sind gleich und D ist anderst und E auch anderst. Ich brauche die ausführliche Schreibweise so das ich sie selbst anbassen kann. Wenn es möglich ist das bei A,B und C dann Dein Code läuft und für D und E wie in meinem Code die Werte in die Zellen dann geschrieben werden.
Da ich bei D und E teils woanderst die Werte übertrage standen die Werte noch immer in den Zellen wenn ich A,B oder C gewählt hatte und daher musste ich meinen Bereich in Tab 1 unschön leeren.
Danke für Deine schnelle Antwort.
Gruß Thomas
Anzeige
AW: Hilfe bei Code
28.08.2011 13:34:52
Tino
Hallo,
"dein Code liest immer die gleiche Zeile aus und schreibt sie in die gleiche Zelle"
Der Code macht eigendlich genau das was in Deinem Beispiel abläuft.
Userbild
Sucht das Jahr in Zeile 3
varCol = Application.Match(lngJahr, .Rows(3), 0)

Sucht den Bereich B, C, D oder E wenn strBereich nicht A ist in der Spalte varCol
If strBereich = "A" Then
varRow = 3
Else
varRow = Application.Match(strBereich, .UsedRange.Columns(varCol), 0)
End If
hier werden die Werte übertragen, varRow + n
    Cells(5, 2) = .Cells(varRow, varCol)
Cells(6, 2) = .Cells(varRow + 1, varCol)
Cells(7, 2) = .Cells(varRow + 2, varCol)
Cells(8, 2) = .Cells(varRow + 3, varCol)
Cells(9, 2) = .Cells(varRow + 4, varCol)
Cells(10, 2) = .Cells(varRow + 5, varCol)
Cells(11, 2) = .Cells(varRow + 6, varCol)
Cells(12, 2) = .Cells(varRow + 7, varCol)
Cells(13, 2) = .Cells(varRow + 8, varCol)
Cells(5, 4) = .Cells(varRow + 9, varCol)
Cells(6, 4) = .Cells(varRow + 10, varCol)
Cells(7, 4) = .Cells(varRow + 11, varCol)
Cells(8, 4) = .Cells(varRow + 12, varCol)
Cells(9, 3) = .Cells(varRow + 13, varCol)
Gruß Tino
Anzeige
AW: Hilfe bei Code
28.08.2011 14:07:31
Thomas
Hallo Tino,
bei A,B und C sind die Zellen wohin der Wert übertragen wird gleich nur in D und E sind sie verschieden
Cells(5, 2) = .Cells(varRow, varCol)
Cells(6, 2) = .Cells(varRow + 1, varCol)
Cells(7, 2) = .Cells(varRow + 2, varCol)
Cells(8, 2) = .Cells(varRow + 3, varCol)
Cells(9, 2) = .Cells(varRow + 4, varCol)
Cells(10, 2) = .Cells(varRow + 5, varCol)
Cells(11, 2) = .Cells(varRow + 6, varCol)
Cells(12, 2) = .Cells(varRow + 7, varCol)
Cells(13, 2) = .Cells(varRow + 8, varCol)
Cells(5, 4) = .Cells(varRow + 9, varCol)
Cells(6, 4) = .Cells(varRow + 10, varCol)
Cells(7, 4) = .Cells(varRow + 11, varCol)
Cells(8, 4) = .Cells(varRow + 12, varCol)
Cells(9, 3) = .Cells(varRow + 13, varCol)
Bei D zb. sollte es so aussehen
Cells(5, 2) = .Cells(varRow, varCol)
Cells(6, 2) = .Cells(varRow + 1, varCol)
Cells(7, 2) = .Cells(varRow + 2, varCol)
Cells(8, 2) = .Cells(varRow + 3, varCol)
Cells(9, 2) = .Cells(varRow + 4, varCol)
Cells(20, 2) = .Cells(varRow + 5, varCol)
Cells(21, 2) = .Cells(varRow + 6, varCol)
Cells(22, 2) = .Cells(varRow + 7, varCol)
Cells(13, 2) = .Cells(varRow + 8, varCol)
Cells(5, 4) = .Cells(varRow + 9, varCol)
Cells(6, 4) = .Cells(varRow + 10, varCol)
Cells(7, 4) = .Cells(varRow + 11, varCol)
Cells(8, 4) = .Cells(varRow + 12, varCol)
Cells(15, 3) = .Cells(varRow + 13, varCol)
und bei E schauts wieder anderst aus.
Hallo Franz,
ich schreib die Werte in werschiedene Zellen weil mir Tab 1 als Formular herhalten soll und ich darin KEINE Formeln haben möchte und da ich nur ein Formular haben will und nicht für A,B,C eins, für D ein eigenes und für E noch eins. Meine Formeln und Berechnungen sind im Tab2 und das/die Ergebnise kommen dann in andere Zelle.
Tabelle2
 AB
3  2009
4RechnungGesamt1Text 1
5RechnungGesamt2Text 2
6RechnungGesamt3Text 3
7RechnungGesamt4Text 4
8RechnungGesamt5Text 5
9RechnungGesamt6Text 6
10RechnungGesamt7Text 7
11RechnungGesamt8Text 8
12RechnungGesamt9Text 9
13RechnungGesamt10Text 10
14RechnungGesamt11Text 11
15AnteilRech1Anteil 1
16AnteilRech2Anteil 2
17AnteilRech3Anteil 3
18AnteilRech4Anteil 4
19AnteilRech5Anteil 5
20AnteilRech6Anteil 6
21AnteilRech7Anteil 7
22AnteilRech8Anteil 8
23AnteilRech9Anteil 9
24AnteilRech10Anteil 10
25AnteilRech11Anteil 11
26Name23 nach m³
27Name24nach m²
28Name25xy
29Name26yz
30Name2728,25%

definierte Namen
Name Bezieht sich auf Tabelle Z1S1-Formel
Liste1=Tabelle2!$B$3:$F$3 =Tabelle2!Z3S2:Z3S6

Tabellendarstellung in Foren Version 5.37


Hoffe es hilft Euch weiter. Ich muss den Code erweitern und wohin was eingetragen anpassen können und das kann ich nur mit der ausführlichen schreibweise. Die verschiedenen Bereiche sind auch unterschiedlich lang ausser A-C sind gleich.
Franz Deinen Code versuche ich gleich mal aus.
Gruß Thomas
Anzeige
AW: Hilfe bei Code
28.08.2011 14:39:19
fcs
Hallo Thomas,
wenn die Zellen, die jeweils ausgefüllt werden, variieren, dann etwa so.
Gruß
Franz
'Code im Modul der Tabelle1
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$3" Or Target.Address = "$C$3" Then
Application.EnableEvents = False
Range("B5:D17").ClearContents
If Range("B3") > 0 And Range("C3")  "" Then
ReadValues
End If
Application.EnableEvents = True
End If
End Sub
Sub ReadValues()
Dim Jahr As Long, Bereich As String
Dim lngRow As Long, lngspalte As Long, pubLngCol As Variant, pubLngRow As Variant
On Error Resume Next
Application.ScreenUpdating = False
Jahr = Range("B3").Value
Bereich = Range("C3").Value
'Spalte mit Jahr in Zeile 3 von Blatt "Sheet2" suchen
With Sheet2
pubLngCol = Application.WorksheetFunction.Match(Jahr, .Rows(3), 0)
'Zeile unterhalb der Zeile mit dem Bereichsnamen ermitteln
pubLngRow = 4 'Zeile für 1. Bereich
'Zeile mit Bereich suchen
pubLngRow = Application.WorksheetFunction.Match(Bereich, .Columns(2), 0) + 1
'oder Zeile mit Bereich fest vorgeben
Select Case Bereich
Case "A":                 pubLngRow = 4
Case "B":                 pubLngRow = 32
Case "C":                 pubLngRow = 52
Case "D":                 pubLngRow = 72
Case "E":                 pubLngRow = 90
Case Else
MsgBox "Bereich """ & Bereich & """ fehlt als Case"
GoTo Beenden
End Select
Select Case Bereich
Case "A", "B", "C"
Cells(5, 2) = .Cells(pubLngRow, pubLngCol)
Cells(6, 2) = .Cells(pubLngRow + 1, pubLngCol)
Cells(7, 2) = .Cells(pubLngRow + 2, pubLngCol)
Cells(8, 2) = .Cells(pubLngRow + 3, pubLngCol)
Cells(9, 2) = .Cells(pubLngRow + 4, pubLngCol)
Cells(10, 2) = .Cells(pubLngRow + 5, pubLngCol)
Cells(11, 2) = .Cells(pubLngRow + 6, pubLngCol)
Cells(12, 2) = .Cells(pubLngRow + 7, pubLngCol)
Cells(13, 2) = .Cells(pubLngRow + 8, pubLngCol)
Cells(5, 4) = .Cells(pubLngRow + 9, pubLngCol)
Cells(6, 4) = .Cells(pubLngRow + 10, pubLngCol)
Cells(7, 4) = .Cells(pubLngRow + 11, pubLngCol)
Cells(8, 4) = .Cells(pubLngRow + 12, pubLngCol)
Cells(9, 3) = .Cells(pubLngRow + 13, pubLngCol)
Case "D"
Cells(5, 2) = .Cells(pubLngRow, pubLngCol)
Cells(6, 2) = .Cells(pubLngRow + 1, pubLngCol)
Cells(7, 2) = .Cells(pubLngRow + 2, pubLngCol)
Cells(8, 2) = .Cells(pubLngRow + 3, pubLngCol)
Cells(9, 2) = .Cells(pubLngRow + 4, pubLngCol)
Cells(20, 2) = .Cells(pubLngRow + 5, pubLngCol)
Cells(21, 2) = .Cells(pubLngRow + 6, pubLngCol)
Cells(22, 2) = .Cells(pubLngRow + 7, pubLngCol)
Cells(13, 2) = .Cells(pubLngRow + 8, pubLngCol)
Cells(5, 4) = .Cells(pubLngRow + 9, pubLngCol)
Cells(6, 4) = .Cells(pubLngRow + 10, pubLngCol)
Cells(7, 4) = .Cells(pubLngRow + 11, pubLngCol)
Cells(8, 4) = .Cells(pubLngRow + 12, pubLngCol)
Cells(15, 3) = .Cells(pubLngRow + 13, pubLngCol)
Case "E"
Case Else
MsgBox "Bereich """ & Bereich & """ fehlt als Case"
GoTo Beenden
End Select
End With
Beenden:
Err.Clear
Application.ScreenUpdating = True
End Sub

Anzeige
AW: Hilfe bei Code
28.08.2011 15:07:50
Thomas
Hallo Franz,
habe den Code direkt in die Tabelle1 kopiert da er im Modul nicht wollte. Dein Code funktoniert und ich kann schön den Code anpassen super und 1000 Dank. Nun kann ich mich weiter dran machen und alles ausbauen.
Schönen Sonntag an alle.
Gruß Thomas
AW: Hilfe bei Code
28.08.2011 13:25:23
fcs
Hallo Thomas,
ich kann das Chaos in deinen vorhanden ReadValues-Prozeduren nicht nachvollziehen. Warum verteilst du die Werte im Bereich B5:D17 so?
Case-Zeile für die Bereiche einfügen.
Gruß
Franz
'Code im Modul der Tabelle1
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$3" Or Target.Address = "$C$3" Then
Application.EnableEvents = False
If Cells(Rows.Count, 2).End(xlUp).Row >= 5 Then
Range(Cells(5, 2), Cells(Rows.Count, 2).End(xlUp).Offset(0, 2)).ClearContents
End If
If Range("B3") > 0 And Range("C3")  "" Then
ReadValues
End If
Application.EnableEvents = True
End If
End Sub
Sub ReadValues()
Dim Jahr As Long, Bereich As String
Dim lngRow As Long, lngspalte As Long, pubLngCol As Variant, pubLngRow As Variant
On Error Resume Next
Application.ScreenUpdating = False
Jahr = Range("B3").Value
Bereich = Range("C3").Value
'Spalte mit Jahr in Zeile 3 von Blatt "Sheet2" suchen
pubLngCol = Application.WorksheetFunction.Match(Jahr, Sheet2.Rows(3), 0)
'Zeile unterhalb der Zeile mit dem Bereichsnamen ermitteln
pubLngRow = 4 'Zeile für 1. Bereich
'Zeile mit Bereich suchen
pubLngRow = Application.WorksheetFunction.Match(Bereich, Sheet2.Columns(2), 0) + 1
'oder Zeile mit Bereich fest vorgeben
Select Case Bereich
Case "A":                 pubLngRow = 4
Case "B":                 pubLngRow = 32
Case "C":                 pubLngRow = 52
Case "D":                 pubLngRow = 72
Case "E":                 pubLngRow = 90
Case Else
MsgBox "Bereich """ & Bereich & """ fehlt als Case"
GoTo Beenden
End Select
lngRow = 5: lngspalte = 2
'Daten für alle namen unterdem Bereich auslesen
Do Until Sheet2.Cells(pubLngRow, 1) = ""
Cells(lngRow, lngspalte) = Sheet2.Cells(pubLngRow, pubLngCol)
pubLngRow = pubLngRow + 1
lngRow = lngRow + 1
Loop
Beenden:
Err.Clear
Application.ScreenUpdating = True
End Sub

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige