Live-Forum - Die aktuellen Beiträge
Datum
Titel
29.03.2024 13:14:12
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1396to1400
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

Daten kopieren vba schleife

Daten kopieren vba schleife
13.12.2014 11:23:11
giuppy

Hallo zusammen,
ich möchte mit eine schleife bestimmte werte kopieren
z.B. der Kdnr Spalte B und kdname spalte C
Kdnr 400 soll in b3 bis b10 und kdname BMW soll in c3 bis C10 kopiert werden und
Kdnr 500 soll in b12 bis b16 und kdname FIAT soll in c12 bis C16 kopiert werden
usw
https://www.herber.de/bbs/user/94381.xlsx
kann mir jemand helfen
danke im voraus
Giuppy
1 KDnr Kdname pos Artikel Beschreibung Menge Ek VK GesEK gesVK
2 400 BMW A
3 B 2 test2 1 12 18 12 18
4 B 3 test3 1 10 15 10 15
5 B 4 test4 1 14 24 14 24
6 B 5 test5 1 20 25 20 25
7 B 3 test3 1 10 15 10 15
8 B 4 test4 1 14 24 14 24
9 B 5 test5 1 20 25 20 25
10 Z 1 test -1 10 15 -10 -15
11 500 FIAT A
12 B 2 test2 1 12 18 12 18
13 B 3 test3 1 10 15 10 15
14 B 4 test4 1 14 24 14 24
15 B 5 test5 1 20 25 20 25
16 Z 1 test -1 10 15 -10 -15
17 600 RENAULT A
18 B 2 test2 1 12 18 12 18
19 B 3 test3 1 10 15 10 15
20 B 4 test4 1 14 24 14 24

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Daten kopieren vba schleife
15.12.2014 07:46:01
giuppy
Hallo,
ich habe das Problem gelöst
Viele Grüße
Giuppy
Sub kopieren()
Dim Ws As Worksheet, Z As Long
Set Ws = ActiveSheet
With Ws
Z = .Range("B" & .Rows.Count).End(xlUp).Row
End With
Application.ScreenUpdating = False ' Bildschirmaktualisierung aus
Sheets("Tabelle1").Activate
xVon = 2
xBis = Z
For ix = xVon To xBis
Kdnr = Range("B" & ix)
If Kdnr = "" Then
Sheets("Tabelle1").Range("B" & ix - 1).Copy _
Destination:=Sheets("Tabelle1").Range("B" & ix)
Sheets("Tabelle1").Range("C" & ix - 1).Copy _
Destination:=Sheets("Tabelle1").Range("C" & ix)  ‘ Kdname
End If
Next
End Sub

Anzeige
Daten kopieren vba schleife
15.12.2014 07:47:19
giuppy
Hallo,
ich habe das Problem gelöst
Viele Grüße
Giuppy
Sub kopieren()
Dim Ws As Worksheet, Z As Long
Set Ws = ActiveSheet
With Ws
Z = .Range("B" & .Rows.Count).End(xlUp).Row
End With
Application.ScreenUpdating = False ' Bildschirmaktualisierung aus
Sheets("Tabelle1").Activate
xVon = 2
xBis = Z
For ix = xVon To xBis
Kdnr = Range("B" & ix)
If Kdnr = "" Then
Sheets("Tabelle1").Range("B" & ix - 1).Copy _
Destination:=Sheets("Tabelle1").Range("B" & ix)
Sheets("Tabelle1").Range("C" & ix - 1).Copy _
Destination:=Sheets("Tabelle1").Range("C" & ix)  ‘ Kdname
End If
Next
End Sub

Anzeige
Bitte schön!
15.12.2014 07:49:11
MCO
Moin!
Solange du dein Blatt so aufgebaut hast, wie im Beispiel sollte es klappen.
Gruß, MCO
Sub Daten_kopieren()
Z = 1 'Zähler
Do While Cells(Z, "A") <> "" 'Solange in A etwas steht
If Cells(Z, "B") = "" Then 'wenn B leer ist
Cells(Z, "B") = Cells(Z - 1, "B") 'Wert in B von oben
Cells(Z, "C") = Cells(Z - 1, "C") 'Wert in C von oben
End If
Z = Z + 1 'Zähler um einen erhöhen
Loop
End Sub

Daten kopieren vba schleife
15.12.2014 07:50:56
giuppy
Hallo,
ich habe das Problem gelöst
Viele Grüße
Sub kopieren()
Dim Ws As Worksheet, Z As Long
Set Ws = ActiveSheet
With Ws
Z = .Range("B" & .Rows.Count).End(xlUp).Row
End With
Application.ScreenUpdating = False ' Bildschirmaktualisierung aus
Sheets("Tabelle1").Activate
xVon = 2
xBis = Z
For ix = xVon To xBis
Kdnr = Range("B" & ix)
If Kdnr = "" Then
Sheets("Tabelle1").Range("B" & ix - 1).Copy _
Destination:=Sheets("Tabelle1").Range("B" & ix)
Sheets("Tabelle1").Range("C" & ix - 1).Copy _
Destination:=Sheets("Tabelle1").Range("C" & ix)  ‘ Kdname
End If
Next
End Sub

Anzeige

299 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige